Forum Moderators: open

Message Too Old, No Replies

syntax error somewhere, can't find it!

would appreciate it if someone could help me here...

         

born2drv

2:37 am on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi guys,

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!

PhraSEOlogy

2:49 am on Aug 11, 2004 (gmt 0)

10+ Year Member



Could it be the quotes around /subcat/page.htm dont match?

<SCRIPT LANGUAGE="JavaScript">urlmaker3("/subcat/page.htm');</script>

born2drv

3:18 am on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think so. Dreamweaver forces it that way, even when I view the source code. And the other scrips are all formatted that way too and they work, so I'm really not sure. It won't let me change it even if I wanted to, it's weird.

Rambo Tribble

5:11 am on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think the quotes may be a problem, too. It's certainly not standard.

Rambo Tribble

3:41 pm on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't confuse the syntax within the document.write(), which is correct with the "~', with the passing of the URL variable in the call to the function urlmaker3(). In the latter case the result is unclosed quotes.

Noisehag

6:53 pm on Aug 11, 2004 (gmt 0)

10+ Year Member



This works:

<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.

StupidScript

11:04 pm on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Specifically, it breaks because you are not correctly ending the declaration of the variable with the quotes.

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>