Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    405
    Thanks
    17
    Thanked 2 Times in 2 Posts

    script works on FF6, but not 3.622

    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...

    Code:
    
    <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:
    Code:
    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 { } 
    }

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Posts
    405
    Thanks
    17
    Thanked 2 Times in 2 Posts
    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?

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,768
    Thanks
    55
    Thanked 518 Times in 515 Posts
    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

  • #5
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by turpentyne View Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •