javascript - jQuery on external text requesting images -


i'm working on chrome extension uses jquery parse source of page specific things. in example i'm looking through wikipedia categories.

i source of page via

chrome.tabs.executescript(tabid, {             code: "chrome.extension.sendmessage({action: 'getcontenttext', source: document.body.innerhtml, location: window.location});" }, function() {     if (chrome.extension.lasterror)          console.log(chrome.extension.lasterror.message); }); 

i listening message (successfully) , use jquery parse source key of object, so

if (request.action == "getcontenttext") {     //console.log(request.source);     $('#mw-normal-catlinks > ul > li > a', request.source).each(function()     {         console.log("category", $(this).html());     }); }  

this works expected , logs list of category links innerhtml. issue happens jquery selector tries load images contained in request.source. results in errors such

get chrome-extension://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/padlock-silver.svg/20px-padlock-silver.svg.png net::err_failed

these valid links, being called (unneeded) extension chrome-extension:// prefix (which invalid). i'm not sure why jquery try evaluate/request images within source using selector

i guess happening because wikipedia uses relative paths on images (instead of https:// or http://, // - content loaded relative server). requests being made jquery , can see here how fix issue (in future, please make sure search more thoroughly).


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -