Today, check yourself with jquery+ajax+php do the website background login detection, found that after the successful landing page jump function this javascript (JS) code effects in IE and Google browser Chrome can be well executed, compatibility is not bad. Results to the Firefox (Firefox) browser settimeout This JS built-in function does not execute, invalid, also did not complain! Open Firebug hope it can detect JS error, the result is useless ... Javascript (JS) script code in the browser compatible is a very headache, after a debugging and search, and finally resolved the settimeout this JS code in Firefox under the failure of incompatible and can not run and execute errors. Currently this settimeout can be well compatible with ie6,7,8,9 as well as Google browser Chrome, Firefox firefox, Apple browser Safari,opera.
SetTimeout is a very good function, Site page front-end engineers often use it for a few seconds after the execution of the action. settimeout This JS built-in function is also very simple to use, the following is the settimeout () function description and usage details and examples, sample code:
The role of settimeout () is to specify how many milliseconds to execute a JS function or expression code
settimeout usage, syntax, parameters: settimeout (code,millisec)
SetTimeout parameter Description:
Code is a required parameter. The JavaScript code string to execute after the function to be invoked.
Millisec is a required parameter. The number of milliseconds to wait before executing the code. The conversion between milliseconds and seconds is: 1000 milliseconds = 1 seconds
SetTimeout Instance Code (page jumps to the specified URL after 1 seconds):
Copy Code code as follows:
<script language= "JavaScript" >
function Go () {//define Functions
Window.location= "main.html";//Page jump
}
Window.settimeout ("Go ()", 1000);//1 seconds to execute function go
</script>
But the above JS code is not compatible with Firefox, this is mainly because IE and Firefox browser engine is different. Let this section of the page Jump JS code compatible with IE, Firefox, SAFARI, OPERA:
Copy Code code as follows:
<script language= "JavaScript" >
function Go () {//define Functions
Window.location= "main.html";//Page jump
}
Window.settimeout (function () {go ()},1000);//1 seconds to execute functions go
</script>
After watching. Bai [kankanbei.com] webmaster test, it is perfectly compatible with the mainstream browser, hereby write to share with you. It is noteworthy that the implementation of page jump JS code We are accustomed to writing location.href= page address, and this code in Firefox is also not run, you need to write window.location= page address.
Firefox browser under the JS code incompatible settimeout function Invalid not run execution solution