Rajesh
Rajesh

Reputation: 2502

passing url as parameter in javascript is not calling the function

<a href="javascript:void();" onclick="openWindow(2,1,4326,http://www.../images/icon_tree1.gif);">Edit Asset Info</a>

Function openWindow is not called and I am see the folowing error on console

Uncaught SyntaxError: Unexpected token : and

Uncaught SyntaxError: Unexpected token )

This is the actual code I am using

return "<a href='javascript:void();' onclick='openWindow(" 2 "," + 1 + "," + 4326 + "," + symbolurl + ");'>Edit Asset Info</a>";

Upvotes: 0

Views: 136

Answers (2)

NoodleFolk
NoodleFolk

Reputation: 2029

You need to pass a string to the onclick handler onclick="openWindow(1, 2, 3, 'http://...')" Some other comments:
1, If your anchor doesn't actually take the user anywhere, consider not to use <a> rather than href="javascript:void();"
2, try not to mix javascript with html. so link your event handler to the DOM element in a <script> tag.

Upvotes: 0

VisioN
VisioN

Reputation: 145368

URL address is a string, so you should surround it with quotes:

... onclick="openWindow(2,1,4326,'http://www.../images/icon_tree1.gif');" ...

Upvotes: 2

Related Questions