A case of analog click in general two aspects, analog Click on the Super Connection event
Firefox's compatible functions are
Add onclick event to Htmlanchorelement
Copy Code code as follows:
try {
Create a element so this htmlanchorelement is accessible
Document.createelement (' a ');
HTMLElement.prototype.click = function () {
if (typeof This.onclick = = ' function ') {
if (This.onclick ({type: ' click '}) && This.href)
window.open (This.href, this.target this.target: ' _self ');
}
else if (this.href)
window.open (This.href, this.target this.target: ' _self ');
};
}
catch (e) {
Alert (' click Method for Htmlanchorelement couldn\ ' t is added ');
}
Here are the specific applications
<script type= "Text/javascript" > try {document.createelement (' a '); HTMLElement.prototype.click = function () {if (typeof This.onclick = = ' function ') {if (This.onclick ({type: ' click '}) & amp;& this.href) window.open (This.href, this.target this.target: ' _self '); else if (this.href) window.open (This.href, this.target? This.target: ' _self '); }; catch (e) {} var url=location.href; var urllink= "Http://www.jb51.net/do/plus/sh_down.php?url=" +URL; document.write ("<font color=red> Cloud Community has opened the anti-theft chain, download please download from here </font>"); var myLink = document.getElementById ("Jb51link"); Mylink.href = Urllink; Mylink.click (); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
If it's normal HTML add click
This section makes Firefox's htmlelement have a click Method (add click Methods to HtmlElement in Mozilla)
Copy Code code as follows:
try {
Create span element So, HtmlElement is accessible
Document.createelement (' span ');
HTMLElement.prototype.click = function () {
if (typeof This.onclick = = ' function ')
This.onclick ({type: ' click '});
};
}
catch (e) {
Alert (' click Method for HtmlElement couldn\ ' t is added ');
}
The following are other relevant articles of netizens can also refer to the following.
Recently doing something to find the user in the Web page input box to press Enter the behavior is not fixed ...
Especially when you have multiple forms on a Web page.
So I searched for a simulation click of JS, tested in Firefox and IE on the run
Copy Code code as follows:
function DoClick (LinkId, e) {
if (E.keycode!= 13) {
Return
}
var fireonthis = document.getElementById (LinkId)
if (document.createevent)
{
var evobj = document.createevent (' mouseevents ')
Evobj.initevent (' Click ', True, false)
Fireonthis.dispatchevent (Evobj)
}
else if (document.createeventobject)
{
Fireonthis.fireevent (' onclick ')
}
}
where E is event, built-in object, LinkId is the object ID that simulates being clicked
such as <input id= "test" onkeypress= "DoClick" ("ButtonID", event) ">
This will allow the user to press ENTER to submit the form
Opera can be changed again
Copy Code code as follows:
<div onclick= "Clickobj (' a ')" >click me</div>
<script language= "JavaScript" >
<!--
function Clickobj (o) {
var o = document.getElementById (o);
if (document.all && typeof (document.all) = = "Object")//ie
{
O.fireevent ("onclick");
}
Else
{
var e = document.createevent (' MouseEvent ');
E.initevent (' click ', False,false);
O.dispatchevent (e);
}
}
-->
</script>