a tag clicks to jump or a confirmation box pops up before form submission

reprint

①html

<a href="http://www.iteye.com" onclick="if(confirm('确认iteye吗?')==false) return false;">iteye</a>

 

②js

function foo(){
    if(confirm("Confirm iteye?")){
	    return true;
	}
	return false;
 }  

 

The label is changed to:

<a href="http://www.iteye.com" onclick="return foo();">iteye</a>

 

1. What we write here is the jump event that occurs when the a tag is clicked to submit.

   The same is true when the form is submitted.

2. The return must be written in the label,

   Otherwise, whether you click OK or not, there will be jumps and in-form submissions.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327042998&siteId=291194637