SitePoint Sponsor

User Tag List

Results 1 to 15 of 15

Thread: refresh()

  1. #1
    SitePoint Zealot Netscape's Avatar
    Join Date
    Apr 2000
    Location
    Toronto, ON, Canada
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    refresh()

    j a v a s r i p t : refresh() <- does not work :-(

    Well, I just want to make a link that will initiate refresh/reload command.

    Any help will be appritiated :-)

    Best Regards,

  2. #2
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    window.refresh() doesn't work?

    Try self.location.href=self.location.href;

    ^^^chunky but it will work.
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2001
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's not refresh() it's reload()

    you can force a page to reload even if it hasn't been altered with:

    Code:
    window.self.reload(true);

  4. #4
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey guys,

    Actually reload() is a method of the location object. So:

    window.location.reload()

    or:

    location.reload()

    aDog

  5. #5
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thanx guys, I only realised on my way up north for the weekend the error of my advice.

    refresh() for forms
    reload() for window.location
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  6. #6
    SitePoint Addict djh's Avatar
    Join Date
    Apr 2000
    Location
    Long Beach, CA
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi guys,

    sorry but I'm a total javascript newbie...

    what if I have a main window and a popup window. I want to have a "CLOSE WINDOW" link on the popup window, and when one clicks it, I want the main window to automatically reload.

    This would be one sweet code, if it'll work...

    This is what I tried, and it doesn't work:

    Code:
    <a href="window.location.reload()" onClick="javascript:window.close();">Close 
      Window</a>
    Thanks!

  7. #7
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Watcha ya talkin about djh?

    I think its parent.location.reload(); not window.location.reload()
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  8. #8
    SitePoint Addict djh's Avatar
    Join Date
    Apr 2000
    Location
    Long Beach, CA
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    say what freddydoesphp?

    that didn't work. i think my problem is that I don't have a parent window defined. how do I do that?

    thanks!

  9. #9
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    To access the window that opened a popup, use window.opener. So:

    Code:
    <a href="javascript:window.opener.location.reload()" onClick="window.close();">Close 
      Window</a>
    You might have to "setTimeout" the close part to make sure the other part runs...I don't think you do, but just in case:

    Code:
    <a href="javascript:window.opener.location.reload()" onClick="setTimeout('window.close()',200)">Close 
      Window</a>
    aDog

    P.S- when you use HREF with javascript, the browser expects a link, so put "javascript:" however, if you are using an event handler (i.e.-onclick), it expects javascript.

  10. #10
    SitePoint Addict djh's Avatar
    Join Date
    Apr 2000
    Location
    Long Beach, CA
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    dude, it didn't work... I'm bummed.

    I tried both bits too and nothing... I get an error on the second one.

    I think the problem is that I'm not referring to the main window properly... or maybe it's because the pop-up window acutally loads a series of different pages...

    Is there any javascript code that makes every browser window refresh (forcefullly!)

    Thanks!

  11. #11
    SitePoint Addict djh's Avatar
    Join Date
    Apr 2000
    Location
    Long Beach, CA
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IT WORKS!!

    I didn't know I had to take out the space between the java and the script.

    Must be because otherwise it will be processed....

    Cool!!

    Thanks dog
    Last edited by djh; Jun 19, 2001 at 10:00.

  12. #12
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was starting to wonder there....

    aDog

    P.S>-I wish this forum software didn't add that space.

  13. #13
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If it didn't you'd be even more mad because the JavaScript executed instead of showing up on the page.
    Kevin

  14. #14
    SitePoint Enthusiast Guni's Avatar
    Join Date
    Jun 2001
    Location
    London (mostly)
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using this on one of my pages:

    window.opener.location.reload(true);

    to force the browser to get a fresh copy from the server. Now this works fine with IE but not with NS. The documentation says that including (true) acts like the reload button.....

    Any ideas?

    Thanks

    Guni

  15. #15
    SitePoint Enthusiast Guni's Avatar
    Join Date
    Jun 2001
    Location
    London (mostly)
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh yeah - just solved it - thanks Arielladog

    with timeout it's working fine

    setTimeout('window.opener.location.reload(true)',200);

    cheers

    Guni
    Last edited by Guni; Aug 28, 2001 at 17:55.


Bookmarks

Posting Permissions

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