Hello people,
The website I’m working on has a top banner that’s loaded from the database. It may be an image, animation, and even HTML code, including <script> tags. Everything is working fine, HTML is loaded correctly, except when I insert a script tag.
Here’s the code I’m using, which partially makes the <script> work in Firefox, but not in any other browser:
[CODE]var div = document.createElement(‘div’);
div.innerHTML = CODE_TAKEN_FROM_DATABASE;
var children = div.childNodes;
topBanner.innerHTML = “”;
for(var i=0;i<children.length;i++)
topBanner.appendChild(children[i]);
I also tried to
[CODE]topBanner.innerHTML = CODE_TAKEN_FROM_DATABASE;
but this didn’t work anywhere.
This is the code [B]in the database
[CODE]<script type=’text/javascript’ defer=’defer’>window.alert(‘o banner deve ser carregado aqui’);</script>
On firefox, this alert message is shown normally. Note that I’ve put the defer attribute, which serves to declare the tag as a script to be executed sometime after page loading, and which should make the tag work on IE, but it doesn’t.
I also tried to load this from the database:
[CODE]<div style=’width:728px; height:90px; overflow:hidden;’><script type=’text/javascript’ src=’http://ads.lomadee.com/as/show.html?mdsrc=23015540&dim=728_90&c=BR&si=33410510&pu=22274844′></script></div>
, which is basically a script that writes an <iframe> with ‘src’ pointing to an external *.swf file. Nothing abnormal. But when this script is loaded, the whole page goes blank, and keeps trying to load something from somewhere, never-ending.
That’s why my method still just PARTIALLY works on Firefox.
Thanks in advance,
Hênio