JavaScript and Back Button

They have: 38 posts

Joined: Dec 2002

I have a link that opens a new page in a resized window that centers on the screen. When I click to another link from that page it stays inside of that window(which I want). However when I click the Back Button to go back to that page it doesnt resize back and center. How can I get when someone clicks back to that page for the page to reload and resize?

The code I am using is:

<script language="JavaScript">
windowWidth=780;
windowHeight=450;
if (parseInt(navigator.appVersion) >= 4) window.moveTo((screen.width/2)-(windowWidth/2+10),(screen.height/2)-(windowHeight/2+20));
</script>

<script language="JavaScript">

</script>

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

When you use the back button you're usually loading the page again from cache, and simply having the script globally is not the same as calling it in an event (I think). So your script isn't probably triggered at all. Try calling it from onload in .

I disallow pages changing my window attributes in Mozilla, so this code will be ineffective to at least one group of users. Not to mention those who disable Javascript entirely, or browse text-only. I don't think it's a good idea to mess with the users interface like that, except in very rare circumstances. Better to leave window sizing to the user. Smiling I hope you're not basing your design on presumed dimensions or anything...

They have: 461 posts

Joined: Jul 2003

i have to agree with abhishek reddy here. it's it VERY bad to adjust sizes. most people i know HATE that and leave the site immediately. the only time they are okay with it is if you open a new window as a reult og them clickingona link.

i have my mozilla to stop certain javascripts: anything to adjust the main winow size and locastion gets killed

this is why mozilla is becoming increasingly popular

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.