PDA

View Full Version : open.window


lou_h99
04-27-2003, 03:53 PM
I have created an open.window function for an Onclick event. It works fine opening the link in a new window with my specified variables.

However everytime you click on one of the links using this it returns the current page back to the top of the screen. I want to leave it at the position the visitor has scrolled too. Is there any way of doing this, Javascript or other?

Any thoughts would be great.........im not that experienced with JS or HTML, so any help please!
:confused:

boywonder
04-27-2003, 04:02 PM
do you have # written in as the href by chance?

do you return false after the function call? like this...

<a href="#" onclick="somefunction(); return false;">

lou_h99
04-27-2003, 04:13 PM
yes the function is defined between script tags in the head of the page like below:

<script>
function popup_window (url_to_get) {
var popup = window.open(url_to_get,'newwindow','toolbar=no,status=no,location=no,menubar=no,resizable=no,scrollb ars=no,left=730,top=300,height=300,width=350,innerHeight=300,innerWidth=350');
return false;
}
</script>

Then when ever I call it I do so like this:

<a href="#" onclick="popup_window('popup.htm')">

The reason I used the # and not nohref is so it still changes the cursor to a hand one over the link (in this particular case the links are images).

that give you more to go on......?

Cheers

boywonder
04-27-2003, 04:15 PM
<a href="#" onclick="popup_window('popup.htm'); return false;">


my preferred way is...

<a href="popup.htm" onclick="popup_window(this.href); return false;">

lou_h99
04-27-2003, 04:17 PM
how will that effect my function that is defined between the script tags? will I need to modify that?

lou_h99
04-27-2003, 04:20 PM
Cool thanks just tried it and it works great.

Thanks

lou_h99
04-27-2003, 04:22 PM
Although in the site I am buidling there is around 40 calls to this function. Thats going to require me changing them all. Is there anyway I can sort this problem out by a re working of the function between the <script> tags?

Cheers

boywonder
04-27-2003, 05:15 PM
Off the top of my head, No... For something shorter you could put:

onclick="return popup_window('popup.htm');">

THere might be a way to adjust them all through scripting, but I would just change them all.

copy- paste?
find-and-replace?

Is 40 small changes really that awful? :D