Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scrollTo call ignored

Status
Not open for further replies.

jaschulz

Programmer
May 20, 2005
89
FR
In the context of an Ajax request, I want to return to the top of the div in question. But, in fact, the scrollTo(0,0) call fails in FF and IE, though it works in Opera. To see the example, goto:


Any suggestions would be appreciated.

Thanks,

JAS
 
I see you are using the ProtoType framework, is this a function within it that doesn't work?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
No, the prototype function does its job. My function looks like this:

function getText(content) {
$('textCol').innerHTML = '';
new Ajax.Request( content, {method: 'get', asynchronous: true, onComplete : function(resp) { $("textCol").innerHTML = addCopyright(resp.responseText);}});
window.scrollTo(0,0);
}

It's the call to window.scrollTo(0,0) that doesn't work (in Opera).

JAS
 
In your first post, you say scrollTo does not work in FF or IE, and does work in Opera, and in your second post, you say it does not work in Opera.

Can you clarify which it is - it clearly cannot be both.

AFAIK, scrollTo was an IE-only method, which Fx has probably implemented, so I'd be surprised if it did work in Opera.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
OK. Found a solution. I put: <a name="top"> at the top of the rightCol div, and then replaced

window.scrollTo(0,0);

with

window.location.replace("#top");

Now it works in all three browsers.

Thanks,

JAS
 
lol - where there's a will there's a way!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
No, <body id="top"> doesn't work for in my case; it gives the same sort of problem that I had with scrollTo(0,0);

What I need is the top of the rightCol div, and so

window.location.replace("#rightCol")

works.

Thanks,

JAS
 
Of course the line I gave you won't work if you're using:

Code:
window.location.replace("#rightCol")

because you have no bookmark named "rightCol". I gave you the line I did when you said you were using:

Code:
window.location.replace("#top");

which you've now changed.

If you use the "#top" line, the ID needs to be "top". Obviously, if you're now using "rightCol", it needs to be "rightCol".

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top