Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy simple innerHTML in Opera

    Hi,
    I'm trying to use the innerHTML property in Opera 7.5. But even a very simple script like the following does not work:

    Code:
    <iframe id="text" width="250" height="50" frameborder="0"></iframe>
    
    <script>
    document.getElementById('text').innerHTML='<center><b>YAHOO</b> </center>';
    </script>
    Anybody knows why?

    -- Kyvinh

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    That would not work in any browser either. iframe is also a window object just like frame.

    Try this:

    <iframe id="text" src="about:blank" width="250" height="50" frameborder="0"></iframe>

    <script>
    document.getElementById('text').document.body.innerHTML='<center><b>YAHOO</b></center>';
    </script>
    Last edited by glenngv; 06-01-2004 at 10:53 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Just an addition to that: You should NEVER, EVER use the character sequence </ in an embedded script. Use <\/ instead.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv
    Try this:
    <iframe id="text" src="about:blank" width="250" height="50" frameborder="0"></iframe>

    <script>
    document.getElementById('text').document.body.innerHTML='<center><b>YAHOO</b></center>';
    </script>
    When trying that, Opera gives me this error:
    Inline script thread
    Error:
    name: ReferenceError
    message: Security error: attempted to read protected variable

    Is there any other way to change the "innerHTML" in modern browsers? Is this just Opera's whims?

  • #5
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Did you read liorean's post?

    Try:
    Code:
    <iframe id="text" src="about:blank" width="250" height="50" frameborder="0"></iframe>
    
    <script>
    document.getElementById('text').document.body.innerHTML='<center><b>YAHOO<\/b><\/center>';
    </script>

  • #6
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    JavaScript is not allowed to reach across domains. You are not only trying to reach across domains, you are trying to reach another protocol that resides on the client. Allowing homepages access to it would be a considerable security risk, one already known to exist and having been exploited to steal username:password tuples from out-of-domain cookies in iew.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #7
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK, thanks everybody. I guess Lioran is right and I just cannot do that.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •