Results 1 to 7 of 7

Thread: random iframe content is white while loading

  1. #1
    Join Date
    Jul 2005
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default random iframe content is white while loading

    Please help...

    Here's the problem:

    As the script loads my random content into the iframe the iframe is a white area. I'm not having transparency problems because when the content loads the background shows through.

    Why is my iframe white while the content is being loaded into it?
    Is this just an Internet Explorer problem?

    Here's the DD script:
    http://www.dynamicdrive.com/dynamici...ndomiframe.htm

    Here's my page:
    http://www.myyoungfamily.com/newhome.htm

    -Jonathan

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The reason is that the iframe isn't populated with anything until the page has otherwise fully loaded because, initially it has no source. Find this line:

    Code:
    document.write('<iframe id="dynstuff" src="add page here" '+iframeprops+'></iframe>')
    I've added in red where you can put a page name. Make a blank page with the same background color as your page and put it here. It will be overwritten in the display by the random content, once the page loads. Sometimes this is not enough. We may need to set its visibility to hidden to begin with then make it visible once the random content is loaded into it. Let me know how the first idea works. I also once made an iframe that had 0 opacity until loaded, that is another approach we could try.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Here is the hiding idea (additions red):

    Code:
    //No need to edit after here
    if (ie||dom)
    document.write('<iframe id="dynstuff" style="visibility:hidden;" src="" '+iframeprops+'></iframe>')
    
    function random_iframe(){
    if (ie||dom){
    var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
    iframeobj.src=randomcontent[Math.floor(Math.random()*randomcontent.length)]
    iframeobj.style.visibility='visible'
    }
    }
    
    window.onload=random_iframe
    
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jul 2005
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That worked great thanks!

    You've made me currious though. How do you set the visibility or make the opacity 0?

    -Jonathan

  5. #5
    Join Date
    Jul 2005
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You read my mind...

  6. #6
    Join Date
    Jul 2005
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well we're 1 for 3...
    Idea 1 worked but idea 2 didn't
    Maybe three is a charm. Can we try the opacity thing?
    -Jonathan

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Looking back over my notes, the opacity trick is very similar to the visibility one, except that I used an on page style sheet to set the initial style for the iframe. That approach may coax the visibility method to work as well. However, it also relied upon having a source for the iframe (as in solution 1 from this thread), guess I was covering all the bases. In short, if method 1 works, stick with it. OK, for the opacity method, put this in the head:

    Code:
    <style type="text/css">
    
    #dynstuff {
    filter:alpha(opacity=0);
    -moz-opacity:0.00;
    opacity:0.00;
    }
    
    </style>
    Add to the script as shown:

    Code:
    function random_iframe(){
    if (ie||dom){
    var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
    iframeobj.src=randomcontent[Math.floor(Math.random()*randomcontent.length)]
    if (iframeobj.filters)
    iframeobj.filters[0].opacity=100;
    else{
    iframeobj.style.MozOpacity=1.0;
    iframeobj.style.opacity=1.0;
    }
    }
    }
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •