SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict jasongr's Avatar
    Join Date
    Jul 2004
    Location
    usa
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to force an iframe to reload?

    Hello

    I have a page A which contains an iframe B which gets loaded with content as the page loads
    Page A has a link. When the link is clicked, I invoke some JavaScript function which performs some tests, and then I would like to have my iframe reload some other URL

    The problem is that I change the iframe's src attribute to the new URL but nothing happens. The iframe isn't reloading.

    How can I force it to reload?
    I heard that it was a problem in IE but that could be a mistake on my part
    It is vital to note that if I clean my browser cache (on IE), then the code works fine once (the iframe gets reloaded). But once it is in the cache, successive attempts fail

    Here is a sample of my code
    Code:
    <head>
    function test() {
      // perform some tests here
      iframe = document.getElementById('RSIFrame');
      iframe.src = 'two.html';
      // iframe.reload(true);  <-- even tried that
    }
    </head>
    <body>
      <a href="javascript: void test();">Run</a>
      <iframe src="one.html" id="RSIFrame" name="RSIFrame" width="200" height="100"></iframe>
    </body>
    Thanks in advance

  2. #2
    SitePoint Zealot coothead's Avatar
    Join Date
    Jan 2005
    Location
    Chertsey, London, England
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there jason,

    you sure get about, don't you.
    Almost as much as me.

    coothead

  3. #3
    SitePoint Addict jasongr's Avatar
    Join Date
    Jul 2004
    Location
    usa
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I try to follow the footsteps of giants

  4. #4
    SitePoint Zealot coothead's Avatar
    Join Date
    Jan 2005
    Location
    Chertsey, London, England
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there jason,

    you could end up splitting your pants.

    coot

  5. #5
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    window.frames['RSIFrame'].location.href="two.html";
    and/or
    window.frames['RSIFrame'].location.reload();

  6. #6
    SitePoint Addict jasongr's Avatar
    Join Date
    Jul 2004
    Location
    usa
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes that solved it
    thanks

  7. #7
    SitePoint Addict jasongr's Avatar
    Join Date
    Jul 2004
    Location
    usa
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was able to solve the bug by passing a random parameter in each invocation of the iframe. This causes the browser to not take the page from the cache


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
  •