jjoz
asked on
Urgent - window scroll / anchor jump in IE4.0x on Mac & PC
I want to be able to jump half way down a long page when the user posts a form to the page.
I have this working in Netscape 4+ on Mac and PC using
document.location='#step3'
in the onLoad function, but have not managed to get it working on IE4.0x
I was hoping to use some sort of anchor jump, rather than scrolling, but using document.location='#step3' to jump does a GET to the page in IE4, rather than just scrolling the already loaded page, resulting in a fresh page, and the posted data being lost from the form I just posted to it.
Also, there are NO form input elements I can focus to (such as text, buttons etc) at the point I want to jump to, just an anchor and plain text. I don't want to add any stange visible elements such as buttons or text inputs.
I have tried the following:
- document.location.hash='#s tep3'
- document.location.hash='st ep3'
- <form ... action="mypage.jsp#step3">
- window.scrollBy(0,300)
- document.anchors.step3.foc us()
- document.anchors.step3.blu r()
- step3.focus()
- step3.blur()
None seem to work in IE4.01 on the Mac... the closest I got was with step3.focus() but the window contents are all messed up.
The correct answer MUST work on IE4.01 on both the Mac and PC. Got Netscape covered :)
Awaiting with baited breath...
I have this working in Netscape 4+ on Mac and PC using
document.location='#step3'
in the onLoad function, but have not managed to get it working on IE4.0x
I was hoping to use some sort of anchor jump, rather than scrolling, but using document.location='#step3'
Also, there are NO form input elements I can focus to (such as text, buttons etc) at the point I want to jump to, just an anchor and plain text. I don't want to add any stange visible elements such as buttons or text inputs.
I have tried the following:
- document.location.hash='#s
- document.location.hash='st
- <form ... action="mypage.jsp#step3">
- window.scrollBy(0,300)
- document.anchors.step3.foc
- document.anchors.step3.blu
- step3.focus()
- step3.blur()
None seem to work in IE4.01 on the Mac... the closest I got was with step3.focus() but the window contents are all messed up.
The correct answer MUST work on IE4.01 on both the Mac and PC. Got Netscape covered :)
Awaiting with baited breath...
Either work in IE5.5 on Windows NT - I expect them to work on IE4 on windows and also on mac
MSDN says
Platform Version
Win16: 4.0
Win32: 4.0
WinCE: 4.0
Unix: 4.0
Mac: 4.0
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/scrollIntoView.asp
MSDN says
Platform Version
Win16: 4.0
Win32: 4.0
WinCE: 4.0
Unix: 4.0
Mac: 4.0
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/scrollIntoView.asp
Here is the xbrowser code
<body onLoad="if (document.all)
document.all('step3').scro llIntoView ();
else if (document.anchors &&
document.anchors['step3'] &&
document.anchors['step3']. x)
window.scrollTo(document.a nchors['st ep3'].x,do cument.anc hors['step 3'].y) ">
and in case you can breathe again: http://www.google.com/search?sourceid=navclient&q=baited+bated
;-)
Michel
<body onLoad="if (document.all)
document.all('step3').scro
else if (document.anchors &&
document.anchors['step3'] &&
document.anchors['step3'].
window.scrollTo(document.a
and in case you can breathe again: http://www.google.com/search?sourceid=navclient&q=baited+bated
;-)
Michel
ASKER
The xbrowser code does work on all 4+ browsers on the PC, but does not seem to work on IE4 OR IE5 on the Mac.
Any further ideas? Any Mac experts out there?
Any further ideas? Any Mac experts out there?
ASKER
Found this on <http://screenporch.com/sp/41/PATCH/>
Browser bug fix: IE 4 and 5 for the Macintosh do not "scroll" properly to new responses in an item.
IE uses "scrollIntoView()" to a <SPAN> to handle showing the 1st new response at the top of the page. IE/Mac doesn't like it if the <SPAN> is empty. For now, just adding a non-breaking space inside the <SPAN></SPAN> works, although it adds a little vertical white space. A better solution will appear later.
Again, <SPAN> seems to work for IE5 on the Mac, but not IE4.01 on the Mac. I am beginning to suspect there is no solution for this problem for Mac IE4.01.
Browser bug fix: IE 4 and 5 for the Macintosh do not "scroll" properly to new responses in an item.
IE uses "scrollIntoView()" to a <SPAN> to handle showing the 1st new response at the top of the page. IE/Mac doesn't like it if the <SPAN> is empty. For now, just adding a non-breaking space inside the <SPAN></SPAN> works, although it adds a little vertical white space. A better solution will appear later.
Again, <SPAN> seems to work for IE5 on the Mac, but not IE4.01 on the Mac. I am beginning to suspect there is no solution for this problem for Mac IE4.01.
Try this:
<head>
<script>
agt = navigator.userAgent.toLowe rCase();
Opera = (agt.indexOf('opera'))
IE = (document.all && !Opera)
IEMac = (IE && agt.indexOf('mac')!=-1);
NS = (navigator.appName=='Netsc ape')
function scrollIt(anc) {
if (IEMac) anc +="mac"
if (IE) document.all(anc).scrollIn toView();
else if (document.anchors &&
document.anchors[anc] &&
document.anchors[anc].x)
window.scrollTo(document.a nchors['st ep3'].x,do cument.anc hors['step 3'].y)
}
</script>
</head>
<body onLoad="scrollIt()">
<SPAN ID="step3mac"><a name="step3"></a></SPAN>
<head>
<script>
agt = navigator.userAgent.toLowe
Opera = (agt.indexOf('opera'))
IE = (document.all && !Opera)
IEMac = (IE && agt.indexOf('mac')!=-1);
NS = (navigator.appName=='Netsc
function scrollIt(anc) {
if (IEMac) anc +="mac"
if (IE) document.all(anc).scrollIn
else if (document.anchors &&
document.anchors[anc] &&
document.anchors[anc].x)
window.scrollTo(document.a
}
</script>
</head>
<body onLoad="scrollIt()">
<SPAN ID="step3mac"><a name="step3"></a></SPAN>
ASKER
Nice attempt, I already implemented something like this, but as I mentioned, it does not work on Mac IE4.01. Apologies for not responding earlier, but the project in question has finished and I had to cut my losses. (shipped without anchor jumping on Mac).
Unfortunately this did not solve the problem, but thanks for trying. I will leave the question open as I am still interested to see an answer if anyone comes up with one.
Unfortunately this did not solve the problem, but thanks for trying. I will leave the question open as I am still interested to see an answer if anyone comes up with one.
You can also ask customer service to PAQ it
Michel
Michel
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
document.all('step3').scro
or
document.anchors('step3').