Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Reloading a page

    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

    Vidda
    Last edited by Lord_Hynarc; 07-11-2005 at 10:39 PM.

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Look into location.reload and location.href.
    Depending on what you need, one of those should suit.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    Regards

    Vidda

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    history.go(-2);

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

  • #5
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    Regards

    Vidda

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Use location.replace(url) instead so that the current page is replaced in the history.

  • #7
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perfect.

    Thank you

    Vidda

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Glad to be of help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •