Home  >  Article  >  Web Front-end  >  window.location.href = window.location.href jump no response a hyperlink onclick event writing method_javascript skills

window.location.href = window.location.href jump no response a hyperlink onclick event writing method_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:25:001421browse

Wrong writing, mainly in href="#"

Copy code The code is as follows:
Wrong writing, mainly in href="#" here

The script is as follows

Copy code The code is as follows:

if (data == "Sent successfully") {
                                           alert(data);
The correct way to write href is followed by javascript:void(0). If it is IE6, it is best to add a return false after onclick

1:

Copy code

The code is as follows:Send
2:

Copy code

The code is as follows:Send
3: This writing method is recommended, ie6 can perfectly support it

Copy code

The code is as follows:Send
The above three ways of writing seem to work, and there is no difference. When the buttonClick function returns return false, it also prevents the function from continuing to run.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn