Forum Moderators: open
<SCRIPT LANGUAGE="JavaScript">
var dir = location.href.substring(0,location.href.lastIndexOf('/')+1);
var url = location.href.substring(dir.length,location.href.length+1);if (url=="page.php") {
document.write('<a href="link.php"><img src="../image.gif" align="top" border="0"></a>');}
else {
document.write('<a href="link.php">
onmouseover="image2.src='../imageon.gif';"
onmouseout="image2.src='../imageoff.gif';">
<img name="image2" src="../imageoff.gif" border="0"></a>');}
</SCRIPT>
I notice that I forgot to 'escape' the forward slashes in the img file/path (I remembered to do so for the closing A tag)
As they're within a 'string', it's unlikely that they'll be parsed as division characters... but I have a hunch that it never hurts to be a purist
else {
document.write(
'<a href="link.php">'
+ ' <img name="image2" src="..\/imageoff.gif" border="0" '
+ ' onmouseover=(image2.src="..\/imageon.gif");'
+ ' onmouseout=(image2.src="..\/imageoff.gif");><\/a>');
}