Let's take a look at the code that simulates the click event:
Copy codeThe Code is as follows: <a href = http://www.jb51.net target = "_ blank" id = "aa"> OK </a>
<Script>
Var comment = document. getElementById ('A ');
If (document. all ){
Comment. click ();
} Else {// Firefox. If the onclick event is not defined in <a>, this section does not work for Firefox.
Var ev = document. createEvent ("MouseEvents ");
Ev. initEvent ("click", true, true );
Document. getElementById ("aa"). dispatchEvent (ev );
}
</Script>
In fact, I trigger a click event on a page mainly to open a new window when submitting a form. Others tend to ignore some basic knowledge, <form> In fact, this function has been provided,
We forget it.Copy codeThe Code is as follows: <form action = "/shopping/index" method = "post" id = "processorder" target = "_ blank" onsubmit = "return checkOrder ()">
<Input name = "button2" type = "submit" id = "button2" value = "" class = "ck_lijisn"/>
</Form>
This code can be submitted in a new window, but note that the button cannot be a button. If you use document. getElementById ("processorder"). submit () in the program, it cannot be implemented.
Submitted in a new window. Haha.
It seems that sometimes things are still traditional.