iframe element in a wml document at runtime

Discussion in 'JavaScript' started by Chirieac, Feb 21, 2010.

  1. #1
    Hello! I want to use an iframe element in a wml document. I know that iframe it's not supported in a wml document, but Opera doesn't care about it and it can use it and I don't care about other browsers :). The problem is that I can't make the iframe work if I add it dynamically.

    In Opera the iframe works if I have this:

    
    <?xml version="1.0"?>
    <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
    <wml>
        <card id="main" title="Title">
            <p>some text</p>
            <iframe src="http://site.com"></iframe>
        </card>
    </wml>
    
    
    Code (markup):
    But if I try to add the iframe at runtime with javacript it doesn't wok:

    
    var iframe = document.createElement('iframe');
    iframe.setAttribute('src','http://site.com');
    iframe.setAttribute('width','200');
    iframe.setAttribute('height','200');
    
    var card = document.getElementsByTagName('card').item(0);
    card.appendChild(iframe);
    
    
    Code (markup):
    The iframe it's added (checked the generated source with opera dragon fly) but it's not displayed!

    Is there a way to make this work?

    Thanks for your time, have a nice day!
     
    Last edited: Feb 21, 2010
    Chirieac, Feb 21, 2010 IP