...

View Full Version : script works on FF6, but not 3.622



turpentyne
09-13-2011, 10:45 PM
I just discovered one of my scripts doesn't work quite right on an older version of Firefox(3.622). It does when I reload the page, but not automatically on initial load Any thoughts on what to change? Here's what I have...





<script type="text/javascript" src="author_find.js"></script>

<img src=/storage/image.gif onload="javascript:doit();" />
<div id="author"></div>



Here is the script it is referencing:


function doit() {
if($('div').hasClass('single-journal-entry-wrapper'))

{

var theURL = null;


var spans = document.getElementsByTagName("span");
for ( var s = 0; s < spans.length; s++ )
{
// searching through spans for the class name:
var span = spans[s];
if ( span.className.indexOf("posted-by") >= 0 )
{
var useit = span.getElementsByTagName("a")[0];
theURL = useit.href;
break; // just the one
}
}
if ( theURL == null )
{
// alert("failed!");
} else {



var parts = theURL.split('/');
var result = parts[parts.length-1];


if (result == "somebodysname") {
var txt=document.getElementById("author");
txt.innerHTML="<table width=100px border=0 cellpadding=0 cellspacing=0 bgcolor=#ffffff><tr><td>content1</td></tr></table>";

} else if (result == "anothername") {


var txt=document.getElementById("author");
txt.innerHTML="content2";

}




}

}else { }
}

Logic Ali
09-13-2011, 10:58 PM
Do you get any error messages in the console when it fails?

Images load asynchronously, so triggering an action based on the loading of an image could give inconsistent results.

turpentyne
09-14-2011, 12:22 AM
No error report comes up. It is on a computer without firebug though. I'm not sure that program works on the older browser.

The asynchronous loading isn't an issue, just so long as the script runs when that image loads.
(I can't put it in the header, because I'm placing scripts on a site that is generated by a third-party blog management programing.)

Would an older browser go to a cached version of the image instead of loading it and cause a problem though?

xelawho
09-14-2011, 12:44 AM
shouldn't this:
img src=/storage/image.gif

be this:
img src="/storage/image.gif" ?

and if you suspect it is getting stuck in the cache, you can add a cache busting parameter

Logic Ali
09-14-2011, 02:41 AM
No error report comes up. It is on a computer without firebug though. I'm not sure that program works on the older browser.
There's still the built-in error console: Under 'Tools' or Ctrl + Alt + J.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum