ok what does externallink.js do? it's a script i picked up from boagworld, anyways it looks for all <a> tags with class="externalLink" , and chnges the clss of those to newWinStyle, and it also opens the link in a new window:
------------------------------------------ function doPopups() { if (!document.getElementsByTagName) return false; var links = document.getElementsByTagName("a"); for (var i=0; i < links.length; i++) { if (links[i].className.match("externalLink")) { links[i].className = links[i].className + " newWinStyle"; links[i].title = links[i].title + " (new window)"; links[i].onclick = function() { window.open(this.href); return false; } } } }
------------------------------ anyways, i'm just wondering why it isn't working!!!
is there some problems when i included an external js into a php include which in turn is included into all my pages?? (ok that sounded confusing but u get what i mean)
Worked like a charm. I'd imagine that the php include is included somewhere within the head-tag, right?
<head> <title>X</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style> .newWinStyle {font: normal 2em verdana;} </style> <script type="text/javascript"> function doPopups() { if (!document.getElementsByTagName) return false; var links = document.getElementsByTagName("a"); for (var i=0; i < links.length; i++) { if (links[i].className.match("externalLink")) { links[i].className = links[i].className + " newWinStyle"; links[i].title = links[i].title + " (new window)"; links[i].onclick = function() { window.open(this.href); return false; } } } } </script> </head> <body onload="doPopups();"> <a href="#" class="externalLink">test</a> <a href="#" class="externalLink">test2</a> <a href="#" class="externalLink">test3</a> </body>
There shouldn't be any difference between the sample code above and using external .js or php includes, as long as they are included in appropriate places.
hmmm weird, i later on thought the problem was due to the fact that getElementsByTagName wasn't supported by Javascript.... guess that's not the reason :S