www.webdeveloper.com
Results 1 to 7 of 7

Thread: Firefox does not like getelementbyid

  1. #1
    Join Date
    Mar 2011
    Posts
    4

    Firefox does not like getelementbyid

    here is the code:

    Code:
    <body onload="loadStream()">
    
    <script type="text/javascript">
    
    function loadStream() { 
    
    document.getElementById('abc').innerHTML; 
    abc.document.write('<script type="text/javascript" src="http://www.domain.com/embed.php?channel=7078&width=530&height=400&autoplay=true"></script>'); 
    
    
    } 
    </script>
    
    <iframe id="abc" src="" width="530" height="400" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" allowtransparency="true"></iframe>


    this works in IE but not Firefox. any ideas?

  2. #2
    Join Date
    Dec 2010
    Posts
    207
    Quote Originally Posted by Jaydog View Post

    Code:
    document.getElementById('abc').innerHTML;
    That line has no effect.

    Try:
    Code:
    function loadStream() { 
    
    document.getElementById('abc').innerHTML = '<script type="text/javascript" src="http://www.domain.com/embed.php?channel=7078&width=530&height=400&autoplay=true"></script>'; 
    
    }


    Q: I found this code...
    A: Then find its author.

  3. #3
    Join Date
    Mar 2011
    Posts
    4
    that doesnt work for writing to an iframe. this does however:

    document.getElementById('abc').src='http://www.domain.com';

    but this only allows urls to be written to the iframe.

    ---
    Tried writing to a DIV instead of an iframe, with:

    document.getElementById('abc').innerHTML = '<script type="text/javascript" src="http://www.domain.com/embed.php?channel=7078&width=530&height=400&autoplay=true"></script>';

    doesnt work either.

    ---
    This works when writing to DIV but only for text elements.

    document.getElementById('abc').innerHTML = 'hello';

    ---

    to make matters worst. not even this works in Firefox, but it does work in IE.

    document.getElementById('abc').innerHTML;
    document.write('<script type="text/javascript"

    src="http://www.directembed.com/embed.php?channel=7078&width=530&height=400&autoplay=true"></script>');

  4. #4
    Join Date
    Mar 2011
    Posts
    4

    Updated Script Execute

    Firefox must have some some sort of script execute security. because even this simple code works in IE, but does not work in Firefox.

    Code:
    function loadStream() { 
    
    document.write('<script type="text/javascript"  src="http://www.domain.com/embed.php?channel=7078&width=530&height=400&autoplay=true"></script>');
    
    }
    
    <body onload="loadStream()">
    
    <div id="abc"></div>

  5. #5
    Join Date
    Dec 2010
    Posts
    207
    You can't call document.write in a loaded document.

    What is your exact intention?


    Q: I found this code...
    A: Then find its author.

  6. #6
    Join Date
    Mar 2011
    Posts
    4

    Updated

    docwrite onload works on every browser available. but heres what we are trying to do.

    loading a .swf per page.

    when page is opened it should pull the .swf file.

    i.e. page1.htm

    function loadStream() {

    document.write('<script type="text/javascript" src="http://www.domain.com/embed.php?channel=1&width=530&height=400&autoplay=true"></script>');

    }

    <body onload="loadStream()">

    <div id="file1"></div>

    --------

    i.e. page2.htm

    function loadStream() {

    document.write('<script type="text/javascript" src="http://www.domain.com/embed.php?channel=2&width=530&height=400&autoplay=true"></script>');

    }

    <body onload="loadStream()">

    <div id="file2"></div>
    -----

    this works in all browsers, except firefox does not allow scripts to be written "onload", only text and images,etc...

    Would love to use innerHTML, but innerHTML does not allow scripts to be written inside of it, or as MS puts it, "the script tag is non-functional inside of an innerHTMl tag".

  7. #7
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    The problem might be related with the way you have written the URL of that script. When you write it as an external URL, IE will block the loading. What prevents you from writing that code straight in the HTML? Or if it is a local file, why using a an absolute URL? Why do you need that document.write() for?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles