SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    refreshing an iframe

    Hi guys,

    How do you refresh an iframe with Javascript?

    I've tried:

    Code JavaScript:
    window.frames["page"].location.reload(); 
     
    //and I've also tried
     
    	var s = document.getElementById('page').src;   
    	document.getElementById('page').src = '';
    	document.getElementById('page').src = s;

    and neither seem to work.. I searched on Google and one forum said it was impossible?

    Any help appreciated..

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried:

    Code JavaScript:
    parent.frames[FrameID].window.location.reload();
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This works in FF2, Safari3 and IE7
    Code:
    var f = document.getElementById("page");
    f.src = f.src; // reloads the iframe
    IE7 didn't like me setting f.src="" and promptly closed.

  4. #4
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r51 View Post
    This works in FF2, Safari3 and IE7
    Code:
    var f = document.getElementById("page");
    f.src = f.src; // reloads the iframe
    IE7 didn't like me setting f.src="" and promptly closed.
    That worked, thanks! All working now. I had previously document.getElementById("page").src = document.getElementById("page").src but that didn't seem to work .. I think. Either way, thanks again.

    Btw - Jimmy's solution didn't work for some reason..


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
  •