vertical scrolling in a newly created window

Y

yootzee

Greetings all,

I'm having a problem with scrolling vertically in a newly created
browser
window. The vertical scrolling is to reach some anchor point within
the new
browser window.

I'm attempting to do this by using an anchor point name of an anchor
located
in the new page as an argument to the JS function opening the new
browser
window. Here's exactly how I'm trying to go about it.

* PageA contains a hyperlink with an onclick event to open a new
page...PageB:
<a href="#" onclick="openPageB( 'someAnchorPoint' ); return false">
where "someAnchorPoint" is the name of an anchor in PageB.

* The JS that I'm using is:
function openPageB( someAnchor )
{
var oNewWin = window.open("/PageB.html", "Help", "width=400,
height=350,
status=no, scrollbars=yes, resizable=yes");
oNewWin.onLoad = window.scrollTo(0, document.anchors[someAnchor]);
oNewWin.focus();
}

My reasoning is based on by belief that document.anchors will return
an integer value based on the geographic location of some given named
anchor within the document object.

What's happening now is that a new browser window is created fine, but
just
can't get the scroll to work; always starts at position 0,0.

Any suggestions are greatly appreciated, and thanks in advance,
yootzee
 
L

Lasse Reichstein Nielsen

* The JS that I'm using is:
function openPageB( someAnchor )
{
var oNewWin = window.open("/PageB.html", "Help", "width=400,
height=350,
status=no, scrollbars=yes, resizable=yes");

Why not just

var oNewWin = window.open("/PageB.html#"+someAncyhor, "Help", ...
oNewWin.onLoad = window.scrollTo(0, document.anchors[someAnchor]);

I don't know if this will work, but in any case "onload" is with all
small letters.
My reasoning is based on by belief that document.anchors will return
an integer value based on the geographic location of some given named
anchor within the document object.

.... and that is an unfounded belief.

The collection "document.anchors" contains HTML elements (i.e., DOM
nodes). It is browser dependent how to find the horizontal offset of
the element on the page. Methods include:

elem.offsetLeft // IE, Opera, Mozilla,
// but not inside positioned elements
elem.scrollLeft // Opera (bug?)
elem.x // Netscape 4

/L
 
Y

yootzee

Thanks Lasse, originally, I was using concatination
("PageB.html#"+someAnchor), and it wasn't working. so, my still being
a little young and naive with JS, I just figured window.open didn't
like that. but, after scrutinizing my scripting, I realized that it
was a PEBCAK error. thanks again for the help. yootzee

Lasse Reichstein Nielsen said:
* The JS that I'm using is:
function openPageB( someAnchor )
{
var oNewWin = window.open("/PageB.html", "Help", "width=400,
height=350,
status=no, scrollbars=yes, resizable=yes");

Why not just

var oNewWin = window.open("/PageB.html#"+someAncyhor, "Help", ...
oNewWin.onLoad = window.scrollTo(0, document.anchors[someAnchor]);

I don't know if this will work, but in any case "onload" is with all
small letters.
My reasoning is based on by belief that document.anchors will return
an integer value based on the geographic location of some given named
anchor within the document object.

... and that is an unfounded belief.

The collection "document.anchors" contains HTML elements (i.e., DOM
nodes). It is browser dependent how to find the horizontal offset of
the element on the page. Methods include:

elem.offsetLeft // IE, Opera, Mozilla,
// but not inside positioned elements
elem.scrollLeft // Opera (bug?)
elem.x // Netscape 4

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top