dongqun1656 2012-05-06 12: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 05: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 雄安新区高光谱数据集的下载网址打不开
  • ¥66 android运行时native和graphics内存详细信息获取
  • ¥100 求一个c#通过CH341读取数据的Demo,能够读取指定地址值的功能
  • ¥15 rk3566 Android11 USB摄像头 微信
  • ¥15 torch框架下的强化学习DQN训练奖励值浮动过低,希望指导如何调整
  • ¥35 西门子博图v16安装密钥提示CryptAcquireContext MS_DEF_PROV Error of containger opening
  • ¥15 mes系统扫码追溯功能
  • ¥40 selenium访问信用中国
  • ¥20 在搭建fabric网络过程中遇到“无法使用新的生命周期”的报错
  • ¥15 Python中关于代码运行报错的问题
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部