JavaScript cancels browser default action

Default action refers to the operation performed by the browser that is not explicitly specified by the user. For certain HTML tags, the browser always has a default action.

http://www.baidu.com

Click the link above, and the browser will pop up a window to enter the Baidu homepage. This action is the default action of the browser: clicking an tag will redirect you to the target page.

Other browser default actions include clicking the submit button to submit the form, clicking the reset button to reset the form, moving the mouse to an element with the title attribute to display a prompt, etc.

The browser's default action can be canceled through JavaScript.

For browsers that follow the W3C specification, use the preventDefault() method of the event object to cancel the default action; however, IE8.0 and below does not support this method. It assigns false to the returnValue attribute of the event object. to cancel the default action.

Cancel the default action of the
tag.

  取消<a>标签的默认动作 
点击这里试试


Continuing Learning
||
取消<a>标签的默认动作
点击这里试试
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!