Hi there, I’m a newbie to this forum, and would be very glad of any help on this. I want to generate a popup window in JS that contains named anchors to facilitate navigation around the popup window document. Everything works fine in IE but neither NS nor Mozilla work correctly.
Here’s a code snippet to demonstrate the effect.
Save it as an html file on your local drive, then try it first in IE, then NS or Mosaic:
<html>
<head>
<script language=’javascript’ type=’text/javascript’>
function problem() {
var out = new Array();
var n = 0;
out[n++] = “<html><body>”
out[n++] = “<h1>Top</h1>”
out[n++] = “<p><a href=’#tp1′>Goto Bottom</a></p>”;
out[n++] = “<p>.</p>n<p>.</p>n”;
out[n++] = “<p><a name=’tp1′></a>Bottom</p>”;
out[n++] = “</body></html>”;
prob_hd = window.open(”,”,’width=260,height=150,scrollbars=1′);
prob_hd.document.write(out.join(“”));
prob_hd.document.close();
prob_hd.focus();
}
</script>
</head>
<body>
<p><a href=’javascript:void problem()’>Popup</a></p>
</body>
</html>
Results (all on Windows XP PC)
[B]IE 6.0
When the popup window opens, clicking on the hyperlink scrolls the popup window document to the desired position
[B]NS4.8
When the popup window opens, clicking on the hyperlink causes the dirctory listing to be loaded into the popup window and scrolled to the bottom.
[B]NS7.1
When the popup window opens, clicking on the hyperlink causes the orginal parent document to be loaded into the popup, nesting the process each time the link is pressed.
[B]Mosaic 1.5
As NS 7.1
Does anyone know of a way to get around this so that I can use named anchors (or an equivalent) to scroll around a document in all browsers? I don’t want to use a window.scroll() method as I don’t klnow what text size may be set and cannot guarantee that absolute positions will be correct – named anchors is by far the best way, but it only seems to work for IE unless I use static content in the popup.
Please help!