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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I open window & scrooll to bottom?

Status
Not open for further replies.

ergot

Programmer
Aug 23, 2003
5
AU
I want to open a new window with a particular web page and then scroll to the bottom of that page (without the benefit of any # tags because the target has none).

This is my code:
Code:
var new_window;
// Functions to open a web page and scroll to the bottom.
function openAndGoBottom () {
new_window = window.open('[URL unfurl="true"]http://www.xe.com/ucc/','newwin');[/URL]
new_window.onload = scrollMe;
}
function scrollMe () {
new_window.scrollTo(0,999999)
}

(The global variable may be a clumsy method: I'm open to suggestions...)
It opens the new window OK but it fails to scroll at all! Can anyone help here?

Denby
 
Both openAndGoBottom() and scrollMe() are in a JS file associated with a JS drop down menu, and openAndGoBottom() is called by a hyperlink on the menu. The URL for the new window is not mine: I have no way of controlling the content of its pages.
 
instead of:

new_window.onload = scrollMe;
Code:
}
function scrollMe () {
new_window.scrollTo(0,999999)
}

try:
scrollMe()
}
function scrollMe () {
new_window.scrollTo(0,999999)
}

Known is handfull, Unknown is worldfull
 
I am trying to do the same except instead of opening a new window can I have a layer that will have links and I can choose a link. Is it possible with javascript

More like: menu-> submenu-> layer with links
 
Hi vbkris

I tried your suggestion and put an alert() command in scrollMe() to see that it worked and yes it's running scrollMe but no luck on the scrolling.

I tried tidying up the code a bit by combining the 2 functions as below and it opens the new window but still no auto bottom scroll. In fact I get a runtime error message 'Access denied' (presumably access to the new window?).
Code:
function openAndGoBottom (theURL) {
	var new_window;
	new_window = window.open(theURL);
	new_window.onLoad = new_window.scrollTo(0,999999);
}
I can see that having the code in the page opening would work but as I said, it's not my page to fiddle with.

Can anyone help me?

Denby
 
can u find the current scroll position in JS? i dont know a function for that. just check that

var new_window;
new_window = window.open(theURL);
new_window.onLoad = new_window.scrollTo(0,999999);
alert(new_window.ScrollPosition())

let me test ur problem in my system...


Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top