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!

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

报告相同问题?