开发者

HTML onclick argument

I would like to know what the return false statement does in this excerpt of HTML code. I don't understand why it isn't just the submit call. I would especially like to know WHERE false is being returned to. The excerpt is from:

http://www.autozone.com/autozone/storelocator/storeLocatorMain.jsp

<\a class="actionButton orange"
    onclick="document.storeLocatorForm.submit();return false;">
 <\span>SUBMIT<\/span>
<\/a>

I know it must have a simple answer but I开发者_Python百科 haven't had much success googling it. I always get people asking much more complicated questions. I took the HTML and JavaScript tutorial at w3schools but it's been a while so I don't really remember how this fits in.


Returning false in an event handler prevents the event from triggering the "default behavior" of the underlying control.

It's common to see this on links:

<a href='/something/useful' onClick='jsMagic();return false;'>
  link text
</a>

The on-click executes your function and then also prevents the user from navigating to /something/useful.


There is a form somewhere on the page called StoreLocatorForm. When the link is clicked, it submits the form data and processes it however the function is programed to.

THe return:false; part is to keep it from not submitting before you actually click the link.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜