Jump to content

IEs not returning to top of page


ctoz

Recommended Posts

:)
<body><a name="top"></a><a href="#top" target="_top">

For the above link and target (copied from your typical W3schools tutorial, "top of the page" link) I'm getting eror messages in IE6 and IE7: but when you follow the eror message suggestions ("back" for 6, and "refresh" for 7) you do get back to the top of the page.I originally had the problem of 6 being dead to href="#top".Any suggestions?

Link to comment
Share on other sites

Nah, you don't have do that junk, just do <a href="http://yoursite.com/index.html#"> the pound sign (#) will take you to the top. You don't need anything after the pound sign or have to add in code to call the top.Edit: lol, I guess it doesn't work on Opera browsers. Works in IE 6, Firefox and Safari

Link to comment
Share on other sites

However, the code I posted works for w3schools in IE6 and 7, but not for me, so I'm none the wiser: and your suggestion, tested offsite, gives the same error messages as the code I posted. The link is absolutlely positioned, maybe that's the problem? Have a look for it: "bad jokes I love 'em" on the bottom right of the page

Link to comment
Share on other sites

I get this error in IE:[removed] Take off the target="_top" code in your link and try it again.

Link to comment
Share on other sites

That ws the problem I referred to. Take of the target and IE6 didn't respond.Never mind, I just took it al back to a href="#" and seems ok all round. Except Opera. What does Opera like?Scratches head: Opera likes

<a href="#top" target="_top">

Link to comment
Share on other sites

I don't know why it's not working on Opera ask justsomeguy, he knows it all. The method you use on the top without the target="_top" should work in all browsers.Edit: I did it on this page and it works fine in IE, Opera, Firefox. [removed]

Link to comment
Share on other sites

No, I do have anchors, I have have them labeled as IDs so my page is valid. You can use names or IDs.<div id="spacer"><a id="top"></a></div><div><a id="bottom"></a></div>

Link to comment
Share on other sites

The Browsers (ie6, ie7, ff, opera, safari, and mac ff, opera, safari) seem to like this:at the top of the page: no anchor at all;and at the bottom:

<a href="filename.htm">top of page</a>

beats me :)

Link to comment
Share on other sites

Yeah, that is because that link simply reloades the page...Are you still having a problem with the # reference?

Link to comment
Share on other sites

Yeah, that is because that link simply reloades the page...
Yup.
Are you still having a problem with the # reference?
Well no, the above will do: but it obviously wouldn't do if I wanted to link to #somewhere_else in the page.To recap: IE6 (not standalone, it's on same pc as IE7) would not respond to
<body><a name="top"></a><a href="#top">...</a>

So I went looking for something that worked for IE6 too. I didn't then think my code was a problem.I found in the W3Schools tutorials pages a version with the underscore hack:

<a href="#top" target="_top">top of page</a>

which works for them, and confirmed me in thinking there was a problem with IE6. But that didn't work on my page either. It gave an error message on both 6 and 7.And essentially, after two round with Opera, that puzzle still exists. Except I've changed the code on the page to the "reload version" above. So I guess I should run the css and the code thru a validator, and try again. There's a lot of layers and clunky js on links at present, which logically shouldn't be a problem but u never know. I'll make a fresh post if I can't solve it.

Link to comment
Share on other sites

Can you post your entire page's code? Maybe the problem is somewhere else on the page.

Link to comment
Share on other sites

[...] I found in the W3Schools tutorials pages a version with the underscore hack [...]
"_top" is one of the target attribute keywords, not a hack, and has nothing to do with an anchor named "top"! The target attribute is most often used with frames. It controls where a document will be opened, for instance in a specified frame or in a new browser window.This doesn't answer your original problem, but it may shed some light because it sounds to me as though the target attribute is confusing matters. If you just want to use named anchors and navigate to them with "#", that works independently of the target attribute. Try ItTo address your original post: can you clarify under what circumstances to you want the browser to "return" to the top of the page? A link to a page will normally open at the top anyway, without any special coding. But use of the back button will show the page as it was, not necessarily at the top.
Link to comment
Share on other sites

"_top" is one of the target attribute keywords, not a hack, and has nothing to do with an anchor named "top"!
... thanks. I remember now. And "_target", which I also tried at some point, didn't work either. Muddled thinking.I only need the page to return to the top from a link at the bottom, in this case about three window-heights down. Reloading the page is ok. (I t also gets Safari to the very top, whereas Safari only seems to go to the first element with <a href="#top">. )
Link to comment
Share on other sites

[...] I only need the page to return to the top from a link at the bottom, in this case about three window-heights down. Reloading the page is ok. (I t also gets Safari to the very top, whereas Safari only seems to go to the first element with <a href="#top">. )
It sounds like just browser variations in treatment of page margin/padding etc above the first named anchor. To achieve what you're asking for across browsers, I think you would need to remove the top margin/padding space before the anchor. For instance:
<body style="margin:0px"><p><a name="verytop" style="padding:0px">Top of page</a></p>

Link to comment
Share on other sites

yesbut if one puts in padding it's usually for a reason :) [...]
Well, quite so! But the same applies to named anchors... and by the sound of it, they are working. The finer window positioning you're asking for is perhaps not to do with THEIR reason for existing!!! Have you thought of doing something in javascript instead? I'd have thought something could be done with an onclick event handler and window.scroll or somesuch....
Link to comment
Share on other sites

Well, quite so! But the same applies to named anchors... and by the sound of it, they are working. The finer window positioning you're asking for is perhaps not to do with THEIR reason for existing!!! Have you thought of doing something in javascript instead? I'd have thought something could be done with an onclick event handler and window.scroll or somesuch....
The "Top" image to the left of this forum uses JavaScript to scroll up. :)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...