SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  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 prevent an IFrame from being loaded automatically

    Hi people

    I have a page which embeds an iframe like so:
    <iframe src="" id="test"></iframe>

    somewhere in my JavaScript code in the page, I set the src attribute of the ifrmae. This causes the iframe to load the page as it should.

    If I leave this page to another and click 'back' in the browser, I return to my page, and the iframe gets loaded automatically, using the last src value it had.

    I don't want that.
    I only want the iframe to load when my JavaScript code modifies the src attribute.

    It is as if the browser remembers in its cache the last value of the iframe src.

    Does anyone know how to solve this problem?

    thanks

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jasongr
    I only want the iframe to load when my JavaScript code modifies the src attribute.
    Try:
    Code:
    window.onload=function(){document.getElementById('myIframe').src='';}

  3. #3
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another avenue might be to use the window.onunload event to set the src="about:blank"


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
  •