How to disable a specific javascript file in Web Browser control in C# -
i'm using web browser control in c# project , want disable specific javascript file. there way that? script loading external website , want disable it. tx
there's great article on @ javascriptkit.com
dynamically removing external javascript or css file:
to remove external javascript or css file page, key hunt them down first traversing dom, call dom's removechild() method hit job. generic approach identify external file remove based on file name, though there other approaches, such css class name. in mind, below function removes external javascript or css file based on file name entered:
function removejscssfile(filename, filetype){ var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type create nodelist var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute test var allsuspects=document.getelementsbytagname(targetelement) (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist matching elements remove if (allsuspects[i] && allsuspects[i].getattribute(targetattr)!=null && allsuspects[i].getattribute(targetattr).indexof(filename)!=-1) allsuspects[i].parentnode.removechild(allsuspects[i]) //remove element calling parentnode.removechild() } } removejscssfile("somescript.js", "js") //remove occurences of "somescript.js" on page removejscssfile("somestyle.css", "css") //remove occurences "somestyle.css" on page
Comments
Post a Comment