Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error - html link calling javascript function

Status
Not open for further replies.
Jul 12, 2001
26
AU
I am having a problem with a syntax error that keeps occuring. I have stripped my page down to see if I had a coding error somewhere, but no, still get the same problem. See code below. The button and the image works just fine only the text link gives the error. The text link executes fine but always gives me a syntax error at the end once I click the OK button for the alert. Doesn't matter what the function is doing, alert or nothing, still gives the same error.

Line: 1
Char: 6
Error: Syntax error
Code: 0
URL: test.htm

<HTML><HEAD><TITLE>Test Page</TITLE></HEAD>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- // Hide from none script compatible browsers
function Display(InputString) {
alert(&quot;This is the input string: &quot; + InputString)
}
// End hiding -->
</SCRIPT>
<BODY>

<A HREF=&quot;javascript:void()&quot; onClick=&quot;Display('Go ahead make my day...')&quot;>Take this string</A>
<form>
<BR><input type=&quot;button&quot; value=&quot;try this string&quot; onClick=&quot;Display('Damn you loch ness monster get off my porch')&quot;>
</form>
<BR><IMG SRC=&quot;test1.gif&quot; onClick=&quot;Display('Typical stinking f$%^ing hot day here in Bombay')&quot; width=&quot;192&quot; height=&quot;96&quot;>


Now character 6 is >
Is there something wrong with my html? Can't I use void and onClick at the same time?

Error occurs in IE 5.5 but not in NN 4.0
OS is Windows NT 4.0 Workstation

puzzled...

AussieClint
 
alert(&quot;This is the input string: &quot; + InputString);
DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Try this..


<HTML><HEAD><TITLE>Test Page</TITLE></HEAD>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- // Hide from none script compatible browsers
function Display(InputString) {
alert(&quot;This is the input string: &quot; + InputString);
}
// End hiding -->
</SCRIPT>
<BODY>

<A HREF=&quot;javascript:Display('Go ahead make my day...')&quot;>Take this string</A>
<form>
<BR><input type=&quot;button&quot; value=&quot;try this string&quot; onClick=&quot;Display('Damn you loch ness monster get off my porch')&quot;>
</form>
<BR><IMG SRC=&quot;test1.gif&quot; onClick=&quot;Display('Typical stinking f$%^ing hot day here in Bombay')&quot; width=&quot;192&quot; height=&quot;96&quot;>

<BODY>
<HTML>
 
yea, or may be

href=&quot;javascript:void(0)&quot; Victor
 
or if none of those work, window.location=&quot;javascript:display()&quot;; -Greg :-Q

flaga.gif
 
DeZiner,

The ; still produced the error, not to worry though.

TodWW,

Simple and pretty obvious to me now, changed my code to

<A HREF=&quot;javascript:Display('Go ahead make my day...')&quot;>Take this string</A>

and no more error, great stuff.

Victor,

javascript:void(0) works as well.

Thank you all for your help,

Clint
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top