I am building my first PHP site and I have a cool javascript snippet to disable links to the current page. The code works great in plain html or ASP, but doesn't function in php. I have spent all day googling and reading forums trying to figure out the rules for injecting JavaScript into a PHP page and haven't really gotten anywhere. The examples I've found seem to contradict one another (or I'm just too ignorant to implement them properly).
My code is as follows:
Code: Select all
<script type="text/javascript" language="javascript">
<!--
function manageLinks()
{
var link;
for (var i = 0; (link = document.getElementsByTagName('a')[i]); i++)
{
if (link.href.indexOf(location.href) != -1)
{
document.getElementsByTagName('a')[i].removeAttribute('href');
}
}
}
window.onload = function() {
manageLinks();
}
-->
</script>
Thanks!