Home Web Front-end JS Tutorial IE browser compatible with Firefox JS script code_javascript skills

IE browser compatible with Firefox JS script code_javascript skills

May 16, 2016 pm 06:59 PM
firefox ie js Browser

1. window.event compatible script
2. Shield Form submission event
3. Get event source
4. Add event compatible writing method
5. Firefox registration innerText writing method
6. Length
7. Child controls under the parent control
8. if(document.all) return window.event;
func=getEvent.caller;
while(func!=null){
var arg0=func.arguments[0];
if(arg0 ){
if((arg0.constructor==Event   arg0.constructor ==MouseEvent)
  (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){
return arg0 ;
}
}
func=func.caller;
}
return null;
}
Firefox needs to use getEvent() to get it every time before using the event. Otherwise it is empty
2. Shield the Form submission event
event.returnValue=false;// for IE
evt.preventDefault();//for firefox
3. Get the event source
var source=event.srcElement //IE
var source=event.target //firefox
4. Add event compatible writing
function addEvent(oElement,sEvent,func){
if (oElement.attachEvent ){
oElement.attachEvent(sEvent,func);
}
else{
sEvent=sEvent.substring(2,sEvent.length);
oElement.addEventListener(sEvent,func, false);
}
}
Usage: addEvent(window,"onload",Start);
5.Firefox registration innerText writing method
//Register firefox innerText
HTMLElement.prototype .__defineGetter__("innerText",
function(){
var anyString = "";
var childS = this.childNodes;
for(var i=0; i if(childS[i] .nodeType==1)
anyString = childS[i].tagName=="BR" ? 'n' : childS[i].innerText;
else if(childS[i].nodeType==3)
anyString = childS[i].nodeValue;
}
return anyString;
}
);
HTMLElement.prototype.__defineSetter__("innerText",
function(sText ; is "children", FireFox is "childNodes"
8. , otherwise a 411 error will occur

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem of third-party interface returning 403 in Node.js environment? How to solve the problem of third-party interface returning 403 in Node.js environment? Mar 31, 2025 pm 11:27 PM

Solve the problem of third-party interface returning 403 in Node.js environment. When we use Node.js to call third-party interfaces, we sometimes encounter an error of 403 from the interface returning 403...

gate.io latest registration tutorial for beginners gate.io latest registration tutorial for beginners Mar 31, 2025 pm 11:12 PM

This article provides newbies with detailed Gate.io registration tutorials, guiding them to gradually complete the registration process, including accessing the official website, filling in information, identity verification, etc., and emphasizes the security settings after registration. In addition, the article also mentioned other exchanges such as Binance, Ouyi and Sesame Open Door. It is recommended that novices choose the right platform according to their own needs, and remind readers that digital asset investment is risky and should invest rationally.

The latest registration tutorial for gate.io web version The latest registration tutorial for gate.io web version Mar 31, 2025 pm 11:15 PM

This article provides a detailed Gate.io web version latest registration tutorial to help users easily get started with digital asset trading. The tutorial covers every step from accessing the official website to completing registration, and emphasizes security settings after registration. The article also briefly introduces other trading platforms such as Binance, Ouyi and Sesame Open Door. It is recommended that users choose the right platform according to their own needs and pay attention to investment risks.

How to avoid being detected by the browser when using Fiddler Everywhere for man-in-the-middle reading? How to avoid being detected by the browser when using Fiddler Everywhere for man-in-the-middle reading? Apr 02, 2025 am 07:15 AM

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...

How to implement cross-application jump for Word plug-in login authorization? How to implement cross-application jump for Word plug-in login authorization? Apr 01, 2025 pm 11:27 PM

How to implement cross-application jump for Word plug-in login authorization? When using certain Word plugins, we often encounter this scenario: click on the login in the plugin...

Jiutian Computing Power Platform Task: Will the computing task continue to run after the local computer is shut down? Jiutian Computing Power Platform Task: Will the computing task continue to run after the local computer is shut down? Apr 01, 2025 pm 11:57 PM

Discussion on the task status after the local computer of Jiutian Computing Power Platform is closed. Many users will encounter a question when using Jiutian Computing Power Platform for artificial intelligence training...

What is the reason for redirecting 404 errors after logging in with Selenium? How to solve it? What is the reason for redirecting 404 errors after logging in with Selenium? How to solve it? Apr 01, 2025 pm 10:54 PM

Solution to Redirecting 404 Errors after Simulation Login When using Selenium for Simulation Login, we often encounter some difficult problems. �...

How to avoid third-party interfaces returning 403 errors in Node environment? How to avoid third-party interfaces returning 403 errors in Node environment? Apr 01, 2025 pm 02:03 PM

How to avoid the third-party interface returning 403 error in the Node environment. When calling the third-party website interface using Node.js, you sometimes encounter the problem of returning 403 error. �...

See all articles