View Full Version : Reloading a page

07-11-2005, 09:48 PM
Hi All,

I am a complete novice at Javascript and am struggling so thought I'd seek help - is that a collective groan I hear?

I suspect that I have probably designed a most complicated way of achieving something very simple. The problem is this. I have a series of PHP programs which access a database and create webpages based on the information therein. In order to provide a good front end to this process I need to have a JS program which finds out the width of the window and passes it into the PHP program. This JS program is in an HTML document. Now I can extract the information and put it into a link on the page using the following statement -

document.write('<a href="fh_sub_index.php?width='+maxWidth+'&name='+strName+'" target="_parent">List of First Names</a>') ;

This works fine. However, I don't want a link; I want the page to load automatically at this point. If I use window.open the page I want, with the required parameters, loads. However, this produces a new window. I want it to load in the existing window. How can I get round this?

Please help me solve this little conundrum - preferably without baffling me with science - me being a 'bear of very little brain'!

Thanks for your help


07-11-2005, 10:13 PM
Look into location.reload and location.href.
Depending on what you need, one of those should suit.

07-11-2005, 10:59 PM
Thanks Nikki,

Setting location.href and using location.reload does exactly what I want. Next question - is there any way that I can still allow the Back button in IE to work? Going Back only reloads the page again - I effectively want it to go back twice.



07-12-2005, 07:25 AM

BTW, just curious, why do you want php to know the width of the window?

07-12-2005, 09:47 AM
Hi Glenn,

Rather than using a table to control the position of the information on the screen, I'm using position:absolute. This will carry on ad infinitum across the page until I tell it to stop. So I have to limit the number of columns which will be written but this changes depending on the size of the window. On my PC I use 1280 width but that is the exception rather than the rule I believe so I have to allow for other sizes. This seemed the easiest way.

The use of position:absolute is because the main body of programs on my site have to use position:absolute to draw a diagram because it has to be able to break across the width of the window.

As I said in an earlier post, I'm sure there is an easier way to do what I am attempting but that's all part of the learning process I guess.



07-12-2005, 10:31 AM
Use location.replace(url) instead so that the current page is replaced in the history.

07-12-2005, 12:18 PM

Thank you


07-12-2005, 02:50 PM
Glad to be of help. ;)