PDA

View Full Version : Text and Image Crawler / replace interHTML not working in FF



brandonthompson
12-04-2009, 04:10 PM
Script: Text and Image Crawler
http://www.dynamicdrive.com/dynamicindex2/crawler/index.htm

When I replace the text the crawler shows it's appending it to the original text in FF. It works correctly in IE...

I put a quick demo of the issue up at:
http://lassoingmonkeys.com/tickerTest3.html

In the demo the bold text "Replacement text" is what was I set the innerHTML of the crawl to.

Anyone have any ideas on this one?

Thanks,
Brandon

jscheuer1
12-04-2009, 05:29 PM
Well, you've done some strange things with my script. It already has a method for initialization that eliminates the need for an onload event. But you have added one anyway. The innerHTML property is non-standard and can cause problems. Crawler avoids its use. Also, IE 7 and less (and IE 8 in quirks mode - what your page is evaluated as) aren't playing with a full deck here since you've placed your crawler in a table. They can't init until after the table is completely parsed, so they add its initialization to a queue that has listened for document load to know when it's OK to proceed. It's a little surprising the init fires at all in those browsers because by the time the init is called, load has technically passed, but I did write things so that a crawler could be initialized at any time. So instead this has somehow simply reversed the execution order of:


marqueeInit({
uniqueid: 'mycrawler2',
style: {
'padding': '5px',
'width': '100%',
'background': 'yellow',
'border': '1px solid #FF0000'
},
inc: 8, //speed - pixel increment for each iteration of this marquee's movement
mouse: 'cursor driven', //mouseover behavior ('pause' 'cursor driven' or false)
moveatleast: 4,
neutral: 150,
savedirection: true
});


and:


document.getElementById("testTicker").innerHTML = "<b>Replacement text</b>";


There is a good chance that if you reverse them, you will get what you want. But it is also possible that may give rise to other unexpected behavior in Firefox and/or IE, not to mention other browsers. Basically what you are attempting is to impose archaic markup and script techniques on an advanced script. It can work out, but there is no guarantee. But I'd give this a try, change:


<script type="text/javascript">
function loadit(){

marqueeInit({
uniqueid: 'mycrawler2',
style: {
'padding': '5px',
'width': '100%',
'background': 'yellow',
'border': '1px solid #FF0000'
},
inc: 8, //speed - pixel increment for each iteration of this marquee's movement
mouse: 'cursor driven', //mouseover behavior ('pause' 'cursor driven' or false)
moveatleast: 4,
neutral: 150,
savedirection: true
});

//alert("1 - "+document.getElementById("testTicker").innerHTML);
document.getElementById("testTicker").innerHTML = "<b>Replacement text</b>";
//alert("2 - "+document.getElementById("testTicker").innerHTML);

}
</script>

to:


<script type="text/javascript">
function loadit(){

document.getElementById("testTicker").innerHTML = "<b>Replacement text</b>";

marqueeInit({
uniqueid: 'mycrawler2',
style: {
'padding': '5px',
'width': '100%',
'background': 'yellow',
'border': '1px solid #FF0000'
},
inc: 8, //speed - pixel increment for each iteration of this marquee's movement
mouse: 'cursor driven', //mouseover behavior ('pause' 'cursor driven' or false)
moveatleast: 4,
neutral: 150,
savedirection: true
});

}
</script>