Js determines the browser type and closes the current window automatically when the width and space of the browser are removed.

Source: Internet
Author: User

// Determine the browser type
Function GetIEType ()
{
Var Sys = {};
Var nvg = navigator. userAgent. toLowerCase ();
Var rslt;
If (window. ActiveXObject)
{
Sys. ie = nvg. match (/msie ([\ d.] +)/) [1];
}
(Rslt = nvg. match (/firefox \/([\ d.] + )/))? Sys. firefox = rslt [1]:
(Rslt = nvg. match (/chrome \/([\ d.] + )/))? Sys. chrome = rslt [1]:
(Rslt = nvg. match (/version \/([\ d.] +). * safari /))? Sys. safari = rslt [1]: 0;
If (Sys. ie)
{
Alert ('ie: '+ Sys. IE );
}
If (Sys. firefox)
{
Alert ('Firefox: '+ Sys. Firefox );
}
If (Sys. chrome)
{
Alert ('chrome: '+ Sys. Chrome );
}
If (Sys. safari)
{
Alert ('safari: '+ Sys. Safari );
}
}
// Enter the full-width space ------------------------
// Replace "empty" with spaces.
String. prototype. trim = function ()
{
Return this. replace (/[delimiter *] | [*]/g ,"");
}
// Remove the left space
String. prototype. ltrim = function ()
{
Return this. replace (/^ [replacement *] | [*]/g ,"");
}
// Remove right space
String. prototype. rtrim = function ()
{
Return this. replace (/[replace *] | [*] * $ /,"");
}
// Match the Email format
Function check_email (email)
{
If (email. match (/^ [-+ 0-9a-z. = _ \/] + @ ([-0-9a-z] + \.) + [a-z] {2, 6} $/I ))
Return true;
Else
{
Alert ("Error! ");
Return false;
}
}
// Close the current window automatically
Window. onload = function ()
{
Window. setTimeout ("next ();", 3000 );
};
Function next ()
{
Alert ("OK ");
}

Related Article

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.