/    Sign up×
Community /Pin to ProfileBookmark

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>[/CODE]

this works in IE but not Firefox. any ideas?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@cluefulMar 26.2011 — 

[CODE]

document.getElementById('abc').innerHTML;
[/code]
[/quote]
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>';

} [/CODE]
Copy linkTweet thisAlerts:
@JaydogauthorMar 26.2011 — 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>');
Copy linkTweet thisAlerts:
@JaydogauthorMar 26.2011 — 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>[/CODE]
Copy linkTweet thisAlerts:
@cluefulMar 27.2011 — You can't call document.write in a loaded document.

What is your exact intention?
Copy linkTweet thisAlerts:
@JaydogauthorMar 28.2011 — 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".
Copy linkTweet thisAlerts:
@KorMar 28.2011 — 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?
×

Success!

Help @Jaydog spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...