Consider this code:
<script type="text/javascript" src="some.js"></script>
<script type="text/javascript" src="some2.js"></script>
<script type="text/javascript">
var scripts = document.getElementsByTagName("script");
for (i=0;i<scripts.length;i++){
if(scripts[i].src=="some.js") {
scripts[i].src = "somechanged.js";
}
}
</script>
<script type="text/javascript" src="some.js"></script>
I dont know why the if is not working. If you comment with // the if it will work for all readed script src. I try some tricks like toLowerCase() and/or valueOf(), but none worked.
I change the if to if(1==1) and of course it works.
What im doing wrong into the string comparison?
Regards
srcproperties are absolute URL. If you want the attribute in the HTML - tryscripts[i].getAttribute("src") === "some.js"console.log(scripts[i].src)in your script and see what is displayed in the javascript debugging console.