Forum Moderators: open
I'm not too good with CSS and I kind of modified some code I already had, but I just can't seem to get it to work...
In my HTML code I have this line:
<SCRIPT LANGUAGE="JavaScript">urlmaker3("/subcat/page.htm');</script>
In my externally loaded javascript file I have this:
var dilink; function urlmaker3(dilink){document.write('<a href="http://www.site.com' + dilink +'">' + '<img src="/images/layout/logo.jpg" width="122" height="52" border="0"></a>');}
I'm trying to get it to output this line:
<a href="http://www.site.com/subcat/page.htm"><img src="/images/layout/logo.jpg" width="122" height="52" border="0"></a>
All it does is take 2 chunks of a URL and puts it together. The point is to prevent Googlebot from spidering it and following the link which is why I don't want to use a regular link.
What am I doing wrong? I'm sure it's just something stupid but I can't see it.
Thanks!
<html>
<head>
<title></title>
<SCRIPT LANGUAGE="JavaScript">var dilink; function urlmaker3(dilink){document.write('<a href="http://www.site.com' + dilink +'">' + '<img src="/images/layout/logo.jpg" width="122" height="52" border="0"></a>');}
</script>
</head><body>
<SCRIPT LANGUAGE="JavaScript">urlmaker3("/subcat/page.htm");</script>
</body>
</html>
As others had already suggested it is the quotes in the function call from the body.
With the improper invocation, as originally posted:
urlmaker3("/subcat/page.htm');
(Opens variable declaration with a double-quote, closes with a single-quote)
your assembled code ends up looking like:
<a href="http://www.site.com/subcat/page.htm');"><img src="/images/layout/logo.jpg" width="122" height="52" border="0"></a>
With the proper invocation posted by Noisehag:
urlmaker3("/subcat/page.htm");
(Opens and closes variable declaration with double-quotes)
your code renders correctly as:
<a href="http://www.site.com/subcat/page.htm"><img src="/images/layout/logo.jpg" width="122" height="52" border="0"></a>