JavaScript error



Hello all,

The following <a> which contains a javascript is causing the

'return statement outside of funcion'

and the link..

<a href="'', '123',
'height=550,width=700, resizable=no, left=20, top=10, scrollbars=yes');
return false;">A link</a>

can anyone please help why?



bruce barker \(\)

when you use href:="javascript:<some code>", you are not defining a
callback, but rather a string to be eval'd. in this case a return is not
valid. this is in constrast to onclick="javascript:<some code>" where you
are defining an anonymous function, so a return is valid.

the html

<button id=btn onclick="alert('hi')">

is the same as

document.getElementById('btn').onclick = function() {alert('hi')} // ie
document.getElementById('btn').onclick = function(event) {alert('hi')}
// w3c compliant browser


<a href="javascript:'<html><body>hello</body></html>'>

is just an eval, thats supposed to return a html string to render as the
current document. if you want to tie script to an anchor, the standard way
is to nav to anonymous bookmark, and catch the onclick event.

<a href="#" onclick="<some code>">

-- bruce (

-- bruce (

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question