turpentyne
09-13-2011, 09: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 { }
}
<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 { }
}