HighDots Forums  

vertical scrolling in a newly created window

Javascript JavaScript language (comp.lang.javascript)


Discuss vertical scrolling in a newly created window in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
yootzee
 
Posts: n/a

Default vertical scrolling in a newly created window - 10-15-2003 , 09:24 PM






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

Reply With Quote
  #2  
Old   
Lasse Reichstein Nielsen
 
Posts: n/a

Default Re: vertical scrolling in a newly created window - 10-16-2003 , 06:49 AM






yootzee (AT) hotmail (DOT) com (yootzee) writes:

Quote:
* 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", ...

Quote:
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.

Quote:
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
--
Lasse Reichstein Nielsen - lrn (AT) hotpop (DOT) com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'


Reply With Quote
  #3  
Old   
yootzee
 
Posts: n/a

Default Re: vertical scrolling in a newly created window - 10-16-2003 , 05:32 PM



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 <lrn (AT) hotpop (DOT) com> wrote

Quote:
yootzee (AT) hotmail (DOT) com (yootzee) writes:

* 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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.