conditional anchor tag control
in html,
<a href="/shop/view-item.php" onclick="checklogin(开发者_C百科);">View Item</a>
As you know, the execution order is,
1) onclick javascript function, checklogin, 2) go to href link, and page refresh, /shop/view-item.php And if you add 'return false' in onclick function's foot, href doesn't work. so the page remain on the same page. The code is,<a href="/shop/view-item.php" onclick="checklogin();return false;">View Item</a>
My question, Can I control 'return false' effect? If user do not log, I want to user remain the same page with alert logging request. If user logged already, let him go the anchor's link url.
Is it possible?
Make sure your checklogin()
function will return true or false appropriately, then do the following:
<a href="/shop/view-item.php" onclick="return checklogin();">View Item</a>
精彩评论