dongqun1656 2012-05-06 20:28
浏览 53
已采纳

菜单不在页面锚点和页面锚点之外

Not really sure how to phrase my question but here's my issue:

I have a php template type site where the main navigation is in it's own file. Some of the navigation buttons point to anchors on the main page and some go to other pages completely.

My original menu used links like index.php# for the on page anchors and index.php?page= for the off page links. I had two issues with this: 1. When I selected an on page link the page seemed to refresh and it was slow taking me to the place on the page the link was connected to. 2. I'm using htaccess to redirect my url from mydomaincom/index.php to mydomaincom/ and found that my nav didn't work in Safari since my href addresses where index.php#value and Safari v5 wouldn't carry over the anchor links.

Rather than turn off my redirect I just changed the urls to point to mydomaincom/#value. Not only did this work great for all browsers but it also made my page quicker.

Now however when I'm on one of the other pages say index.php?page=photos and I use the nav it just tries to find the anchors on that page (which makes sense but obviously not what I want). What it's doing now: mydomaincom/index.php?page=photos#

What I need it to do: mydomaincom/#

Since the same nav file is used for all pages do I need to create a nave link variable so that when the nav is on a non-index.php page the link urls that hook to the index.php on page anchors uses the full url?

Hopefully this makes sense. Any suggestions? Also trying to keep this search engine/Google friendly :)

Thanks!

  • 写回答

1条回答 默认 最新

  • dongye9071 2012-05-08 13:32
    关注

    While I could have hard coded it I instead created a php variable called $index which I set in the initial settings file loaded first. I set the variable to mydomaincom/# and then updated the nav button links which are onpage anchors to . I didn't need to make it a variable but it means I could change it easier in the future if I need too.

    All my nav links that point to anchors on the index.php page are formatted like mydomaincom/# and off page links mydomaincom/page?=. Made sure this worked when using the menu on the index.php page and off pages as well as checked speed and functionality in all browsers.

    Thanks!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。