This is a migrated thread and some comments may be shown as answers.

a[i].getAttribute("href") is null in Firefox 3

4 Answers 71 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Wei
Top achievements
Rank 1
Wei asked on 10 Dec 2008, 04:05 PM

umm... what is this error I see on every pages?

a[i].getAttribute("href") is null


It seems in this function: (line 33 is where it breaks)

// Iterates through all the <a> links on a page and adds   
// them to the queue to be prefetched.  
function doEnhancedPrefetch(aEvent, pos) {  
 
    // exit if enhanced prefetching is turned off  
    // or if the site has opted out of prefetching  
    if(!PreferencesService.getBoolPref("extensions.fasterfox.enhancedPrefetching")) return;  
      
    // doc is document that triggered "onload" event  
    var doc = aEvent.originalTarget;   
      
    // if this isn't an http:// page, retun  
    if (doc.location.href.indexOf("http://") != 0) return;  
          
    // load whitelist  
    var whitelist = PreferencesService.getCharPref("extensions.fasterfox.whitelist").split(",");  
    var whitelistLen = whitelist.length;  
      
    // find all links  
    var a = doc.getElementsByTagName('a');  
    var href, numLinksToPrefetch, i, j;  
      
    // prefetch a max of 100 links  
    numLinksToPrefetch = (a.length>100) ? 100 : a.length;  
 
    // if its the first time, set the pos to 0,  
    // if a pos was passed in, we'll start the for loop there instead  
    if (pos == null || pos <=0) pos = 0;  
      
    // iterate through the links  
    mainLinkLoop:   
    for (i=pos; i<numLinksToPrefetch; i++) {  
        href = a[i].getAttribute('href').toLowerCase();  
          
        // make sure there is a link  
        if(href && href.length > 4) {  
 
            // Don't prefetch links w/ query strings  
            // or the same page we are on  
            if(href.indexOf('?')>=0 || href == doc.location.href) continue;  
              
            // Don't prefetch things that look like a logout link  
            // Special thanks to b1naryb0y and Kai Risku for this bug fix  
            if(href.indexOf('logout')>=0 || href.indexOf('logoff')>=0) continue;  
              
            // Only prefetch static content, this causes dynamic pages to be ignored  
            fileExtensionStartPos = href.length-4;  
            if(!(href.indexOf('.htm') == fileExtensionStartPos   
              || href.indexOf('.html') == fileExtensionStartPos-1  
              || href.indexOf('.jpg') == fileExtensionStartPos  
              || href.indexOf('.gif') == fileExtensionStartPos  
              || href.indexOf('.png') == fileExtensionStartPos  
              || href.indexOf('.jpeg') == fileExtensionStartPos-1  
              || href.indexOf('.txt') == fileExtensionStartPos  
              || href.indexOf('.text') == fileExtensionStartPos-1  
              || href.indexOf('.xml') == fileExtensionStartPos  
              || href.indexOf('.pdf') == fileExtensionStartPos)) continue;  
                
            // Don't prefetch whitelist links  
            href = ff_GetAbsoluteUrl(href, doc.location.href);  
            for(j=0; j<whitelistLen; j++) {  
                if(whitelist[j].length > 0 && href.indexOf(whitelist[j]) >= 0) continue mainLinkLoop;                 
            }  
              
            // test if site is opting out of prefetching  
            var shouldOptOut = ff_IsSiteOptOut(href, aEvent, i);  
            if(shouldOptOut) {  
                continue;  
            } else if (shouldOptOut == -1) {  
                return;  
            }  
              
            try {  
                PrefetchService.prefetchURI(ff_makeURI(ff_GetAbsoluteUrl(a[i].getAttribute('href'), doc.location.href)), ff_makeURI(doc.location.href), true);  
            } catch(e) {   
                //if(e.name != "NS_ERROR_ABORT") alert(ff_GetAbsoluteUrl(href, doc.location.href) + '\n' + e.toString());   
            }  
        }  
    }  
 
}  
 

4 Answers, 1 is accepted

Sort by
0
DGDev
Top achievements
Rank 2
answered on 22 Dec 2008, 03:23 AM
I have the same problem.
Have not yet pin-pointed whats causing it though. Strange it only exists with Firefox 3.

http://www.example.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_ctl00_ScriptManager_HiddenField&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d3.5.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3a8ac4a3ed-a467-4f19-a8ed-9270f6e4c6d6%3aadbe97d5%3a6a5df9aa%3bTelerik.Web.UI%2c+Version%3d2008.3.1105.35%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3a99dd44ed-99f9-4eed-a93e-6ebfddaf3eb2%3afe8d4455%3a170a45d3%3adcf52240%3ac7991a52%3acc662d70%3a3e33fb52%3a9265f342%3a5f3d0562%3afe3916f2%3ab33f49a2
0
Sebastian
Telerik team
answered on 22 Dec 2008, 07:41 AM
Hi guys,

Can you please verify that this issue appears under FireFox 3 browser only and prepare a working demo (using our RadScriptManager control) which replicates it? Thus we will be able to investigate the matter further and provide an accurate explanation/solution. You can attach the example to a regular support ticket in order to send it to us.

Kind regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Wei
Top achievements
Rank 1
answered on 22 Dec 2008, 02:30 PM
My problem is related to add-in FasterFox. With the removal of FasterFox the problem solved itself!
0
Accepted
DGDev
Top achievements
Rank 2
answered on 22 Dec 2008, 07:15 PM
Funny you should mention that, I just installed FasterFox today. I never saw any error before installing it, so this must be the cause.

If you disable "Enhanced Prefetching", you will not receive this error anymore.
Tags
General Discussions
Asked by
Wei
Top achievements
Rank 1
Answers by
DGDev
Top achievements
Rank 2
Sebastian
Telerik team
Wei
Top achievements
Rank 1
Share this question
or