开发者

Named anchors issues with Safari and wordpress nav menu

开发者 https://www.devze.com 2023-01-23 08:44 出处:网络
Hey guys, I\'ve tried asking this at the wordpress forums, but I\'m not getting much useful assistance...

Hey guys, I've tried asking this at the wordpress forums, but I'm not getting much useful assistance...

I've recently built a site for someone, which I'm currently testing (http://www.audaciousdreaming.com/test/), and I'm having a bit of an issue with Safari.

Basically, as开发者_JAVA百科 can be seen on the site, the drop down menu links are just linking to named anchors within each page. This works perfectly with Firefox, Opera and IE, but Safari doesn't seem to 'see' the hashtag for the anchor in the link. It seems happy enough with the 'top of page' links, but the menu items do not play nice. I've tried with named anchors, named spans, using the 'name' parameter as well as 'id', but nothing works.

I found a forum post somewhere (which I've now managed to lose) that said that if there is some sort of redirect in the page header that Safari will pick this up and lose it's memory of #tags in a way that other browsers won't- I don't know if this is a known issue with Safari? Is there any easy fix?


Interesting -- you can actually see the site redirecting from

http://www.audaciousdreaming.com/test/index.php?page_id=18#Volunteers 

to

http://www.audaciousdreaming.com/test/?page_id=18

... so presumably it's the rewriting out of the index.php that's causing the problem. mod_rewrite, from what I remember, can't "carry across" the fragment, so relies on the browser to do that, and Safari isn't doing it.

As a quick and dirty solution, could you simply change the links so they already omit the index.php and therefore don't get rewritten? That will presumably stop your site doing an unnecessary redirect, too, which can't be a bad thing...


I had a similar problem linking to in-page anchors. However, my problem involved javascript that was overwriting the link to the specific anchor and resetting the page to the top of the window.

Have you tried browsing the stack exchange site WordPress Answers? Here's my question there...with a jQuery solution to scroll to a named post id on a page.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号