write to iframe in Opera

Discussion in 'Javascript' started by juergen.riemer@chello.at, Apr 16, 2006.

  1. Guest

    Hi all,

    I create an IFrame and want to dynamically add content to it in Opera
    (8.54) like this:

    <html>
    <body>
    <script>
    oPanel = document.createElement("IFRAME");
    oPanel.src = "about:blank";
    document.body.appendChild(oPanel);
    oPanel.addEventListener("load", function(){
    var oImage = oPanel.contentDocument.createElement("IMG");
    oPanel.contentDocument.body.appendChild(oImage);
    }, false);
    </script>
    </html>
    </body>

    I get the following error message:

    -----
    Event thread: load
    Error:
    name: Error
    message: Security violation
    -----

    I learned about problems Opera has to not apply anti cross domain
    policy when dealing with frames. But how to solve this? Any idea?

    greetz

    mord
    , Apr 16, 2006
    #1
    1. Advertising

  2. wrote:

    > I create an IFrame and want to dynamically add content to it in Opera
    > (8.54) like this:


    With Opera 8.5 on Windows I managed that with an enforced delay using
    setTimeout e.g.

    var iframe = document.createElement('iframe');
    iframe.addEventListener(
    'load',
    function (evt) {
    var doc = iframe.contentDocument;
    var p = doc.createElement('p');
    p.appendChild(doc.createTextNode('Kibology for all.'));
    doc.body.appendChild(p);
    },
    false
    );
    document.body.appendChild(iframe);
    setTimeout(function () {
    iframe.contentWindow.location.href = 'dummy.html';
    }, 10);

    where dummy.html simply has the basic
    <htm><head><title></title></head><body></body></html> structure of an
    HTML document.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Apr 16, 2006
    #2
    1. Advertising

  3. Guest

    Martin,

    Ingenious! Loading the iframe with a dummy which indicates it being
    from the same domain, I just had to replace
    oPanel.src = "about:blank";
    with
    oPanel.src = "dummy.html";
    to make it work.
    It was my ignorance about how browsers would deal with "about:blank"
    (same with my other post about relative paths in iframes created with
    "about:blank"

    thanks a lot
    , Apr 16, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob
    Replies:
    24
    Views:
    1,527
  2. cx
    Replies:
    1
    Views:
    4,909
    BootNic
    Aug 10, 2007
  3. Øyvind Granberg

    iframe in ie & ff & Chrome & Opera

    Øyvind Granberg, Dec 5, 2008, in forum: HTML
    Replies:
    5
    Views:
    11,821
    Øyvind Granberg
    Dec 6, 2008
  4. Daedalous
    Replies:
    3
    Views:
    662
    Daedalous
    Jan 16, 2004
  5. Paul Fi

    iframe resizing on opera problem

    Paul Fi, Nov 18, 2004, in forum: Javascript
    Replies:
    2
    Views:
    85
    Paul Fi
    Nov 19, 2004
Loading...

Share This Page