Imitate click event in IE and Firefox and submit to new window summary (asp.net) _ Practical Tips

Source: Internet
Author: User
First look at the code that simulates the Click event:
Copy Code code as follows:

<a href=http://www.jb51.net target= "_blank" id= "AA" >ok</a>
<script>
var comment = document.getElementById (' AA ');
if (document.all) {
Comment.click ();
else {//Firefox, if the onclick event is not defined in <a>, this paragraph does not work for Firefox
var ev = document.createevent ("mouseevents");
Ev.initevent ("Click", True, true);
document.getElementById ("AA"). dispatchevent (EV);
}

</script>

In fact, I am in the page to trigger a click event in order to submit the form, in the form of a new window open, we often ignore some basic knowledge,<form> actually has provided this function,

It's just that we forgot about it.
Copy Code code 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>

Such code can be completed in a new window submission, but note that buttons cannot be button if you use document.getElementById ("ProcessOrder") in the program. Submit () is not implemented

Submitted in a new window. Oh.

It seems that sometimes things are still good in tradition.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.