Welcome to WebmasterWorld Guest from 54.163.166.22

Forum Moderators: incrediBILL

Message Too Old, No Replies

anchors within iframe with Firefox

anchors won't work within iframe with Firefox

     
1:26 pm on Mar 30, 2011 (gmt 0)

New User

5+ Year Member

joined:Mar 30, 2011
posts: 4
votes: 0


Hello all,


I have a problem with simple anchors. The page that contains the anchors is in an iframe. It works fine with IE and Safari but won't work with Firefox 4.0.
The code I use:
<a href="#anchor">to anchor</a>
<a id="anchor"></a>

I know it's an iframe problem. The page works fine with Firefox if the page in question is not within an iframe. Does anybody know a solution to my problem or a work around.

-Thanks.
2:05 pm on Mar 30, 2011 (gmt 0)

Administrator from US 

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 25, 2005
posts:14650
votes: 94


Hi Izzy and welcome to WebmasterWorld.

It's not an iframe thing, it's an anchor attribute thing.

Try using the "name" attribute and it might work properly: <a name="anchor"></a>
3:20 pm on Mar 30, 2011 (gmt 0)

New User

5+ Year Member

joined:Mar 30, 2011
posts: 4
votes: 0


Hi incrediBILL,

thanks for your quick response. I did try with "name" instead of "id" and still doesn't work. As I mentionned, if I display the page outside the iframe, the anchors works perfectly with Firefox. That's why I thought it was a iframe problem. Could there be some setting with Firefox that I'm not aware of?

Izzy
3:26 pm on Mar 30, 2011 (gmt 0)

Administrator from US 

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 25, 2005
posts:14650
votes: 94


Could it be a window focus thing?

Like you need to select the iframe before it works within the iframe?
4:45 pm on Mar 30, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


Did you try it on a non-empty element? It doesn't have to be an anchor.

<a href="#anchor">to anchor</a>
<h2 id="anchor">Topic three</h2>

I just tested it using ID's but don't have 4.0, maybe it's specific to 4.0 - did you validate all documents?
5:30 pm on Mar 30, 2011 (gmt 0)

New User

5+ Year Member

joined:Mar 30, 2011
posts: 4
votes: 0


Hi Rocknbil,

thanks for your input!

It is a 4.0 thing...Someone I know tested it with a previous version of Firefox and it's workin fine....
I did also try with an non-empty element and with "id' and still doesn't work...I will look into what incrediBILL suggested and see...
Will post the fix if I find one!
5:44 pm on Mar 30, 2011 (gmt 0)

Administrator from US 

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 25, 2005
posts:14650
votes: 94


if it's a FF 4 thing I'd go report the bug to them then because I found lots of little quirks in FF 4 and bailed on it.

BTW, why do both of you use the ID attribute instead of the NAME attribute?

I trust W3C's definition of this: [w3schools.com...]

Although ID might work, NAME is what it's always supposed to have been for this purpose if I'm not mistaken.
7:02 pm on Mar 30, 2011 (gmt 0)

New User

5+ Year Member

joined:Mar 30, 2011
posts: 4
votes: 0


Actually, it's a note I read from the w3school site. They say that the upcoming HTML5 standard suggest using the id attribute instead"...

I'll report the bug to FF 4
7:22 pm on Mar 30, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


Name is deprecated [w3.org] for non form elements in XHTML. It will still work for anchors and don't think it's deprecated in other doctypes, but it's a habit thing for me - name for form elements, id for DOM objects.
8:35 pm on Mar 30, 2011 (gmt 0)

Administrator from US 

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 25, 2005
posts:14650
votes: 94


Ah, an HTML 5 thing, good to know.

You can see how I'd be confused with the W3C docs I linked which are currently coming to the top for the query ;)

I know what I know if you know what I mean, and now I know more!
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members