Js according to different browser pop-up windows

Source: Internet
Author: User

1 ///<reference path= "Intellisense/jquery-1.2.6-vsdoc.js"/>2 varUserAgent =navigator.userAgent.toLowerCase ();3 varIs_opera = Useragent.indexof (' opera ')! =-1 &&opera.version ();4 varIs_moz = (Navigator.product = = ' Gecko ') && useragent.substr (Useragent.indexof (' Firefox ') + 8, 3);5 varUa_match =/(Trident) (?:. *RV: ([\w.] +))?/.exec (useragent) | | /(MSIE) ([\w.] +)/. EXEC (useragent);6 varIs_ie = Ua_match && (ua_match[1] = = ' Trident ' | | ua_match[1] = = ' Msie ')?true:false;7 8 functionLoaddialogwindow (URL, parent, loc_x, loc_y, width, height) {9     if(Is_ie)//window.open (URL);Tenwindow.showModalDialog (URL, Parent, "Edge:raised;scroll:1;status:0;help:0;resizable:1;dialogwidth:" + width + "px; Dialogheight: "+ height +" Px;dialogtop: "+ loc_y +" Px;dialogleft: "+ loc_x +" px ",true); One     Else Awindow.open (URL, parent, "height=" + height + ", width=" + width + ", Status=0,toolbar=no,menubar=no,location=no, Scrollbars=yes,top= "+ loc_y +", left= "+ loc_x +", Resizable=yes,modal=yes,dependent=yes,dialog=yes,minimizable=no ",true); - } - functionAddUser (inputid) { the  -URL = "user.aspx?inputid=" +inputID; -loc_y = loc_x = 200; -Height = 450; +     if(is_ie) { -loc_x = Document.body.scrollLeft + event.clientx-100; +loc_y = document.body.scrollTop + event.clienty + 100; AHeight + = 50; at     } -Loaddialogwindow (URL, Self, loc_x, loc_y, 550, height);//This sets the width and height of the window - } - //Get parent window value - functionGetUserName (inputid) { -     if(Is_ie) in         returnWindow.dialogArguments.document.getElementsByName (inputID) [0].value; -     Else to         returnwindow.parent.opener.document.getElementById (inputID). value; + } -//Setting the parent window value the functionSetusername (inputID, users) { *     if(Is_ie) $Window.dialogArguments.document.getElementsByName (inputid) [0].value =users;Panax Notoginseng     Else -Window.parent.opener.document.getElementById (inputid). Value =users; the } +  A Try{Document.execcommand ("Backgroundimagecache",false,true); }Catch(e) {} the varPopupwin; + functionPopupcenterwindow (urlstr, width, height, newwin, scrollbars) { -     varPopupwin = 0; $     if(typeof(newwin) = = "Undefined") { $Newwin =false; -     } -     if(typeof(scrollbars) = = "Undefined") { thescrollbars = 0; -     }Wuyi     if(typeof(width) = = "Undefined") { thewidth = 800; -     } Wu     if(typeof(height) = = "Undefined") { -Height = 600; About     } $     varleft = 0; -     vartop = 0; -     if(Screen.width >=width) { -left = Math.floor ((screen.width-width)/2); A     } +     if(Screen.height >=height) { thetop = Math.floor ((screen.height-height)/2); -     } $     if(newwin) { theOpen (Urlstr, ', ' toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars= ' + scrollbars + ', resizable =yes,copyhistory=yes,width= ' + width + ', height= ' + height + ', left= ' + Left + ', top= ' + Top + ', screenx= ' + left + ', SCR Eeny= ' + top + '); the         return; the     } the  -     if(Popupwin) { in         if(!popupwin.closed) Popupwin.close (); the     } thePopupwin = open (urlstr, ' Popupwin ', ' toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars= ' + ScrollBars + ', resizable=yes,copyhistory=yes,width= ' + width + ', height= ' + height + ', left= ' + Left + ', top= ' + Top + ', Screenx= ' + Left + ', screeny= ' + Top + '); About Popupwin.focus (); the } the  the functionopenmodelwindow (URL, option) { +     varFun ; -     Try { the         if(Parent! =NULL&& parent.$! =NULL&& parent.$. Showifrmdailog! =undefined) {BayiFun =parent.$. Showifrmdailog the         } the         Else { -Fun = $. Showifrmdailog; -         } the     } the     Catch(e) { theFun = $. Showifrmdailog; the     } - Fun (URL, option); the } the functionClosemodelwindow (callback, dooptioncallback) { the Parent.$.closeifrm (callback, dooptioncallback);94 } the functionStrformat (temp, dataarry) { the     returnTemp.replace (/\{([\d]+) \}/g,function(S1, S2) {vars = dataarry[s2];if(typeof(s)! = "undefined") {if(sinstanceof(Date)) {returnS.gettimezoneoffset ()}Else{returnencodeURIComponent (s)}}Else{return"" } }); the }98 functionStrformatnoencode (temp, dataarry) { About     returnTemp.replace (/\{([\d]+) \}/g,function(S1, S2) {vars = dataarry[s2];if(typeof(s)! = "undefined") {if(sinstanceof(Date)) {returnS.gettimezoneoffset ()}Else{return(s); } }Else{return""; } }); - }101 functionGetiev () {102     varUserAgent =window.navigator.userAgent.toLowerCase ();103$.BROWSER.MSIE8 = $.browser.msie &&/msie 8\.0/i.test (useragent);104$.browser.msie7 = $.browser.msie &&/msie 7\.0/i.test (useragent); the$.browser.msie6 =!$.browser.msie8 &&!$.browser.msie7 && $.browser.msie &&/msie 6\.0/i.test (useragent);106     varv;107     if($.BROWSER.MSIE8) {108V = 8;109     } the     Else if($.browser.msie7) {111v = 7; the     }113     Else if($.browser.msie6) { thev = 6; the     } the     Else{v =-1; }117     returnv;118 }119$ (document). Ready (function() { -     varv =Getiev ()121     if(V > 0) {122$ (document.body). addclass ("ie ie" +v);123     }124  the });126    

Js according to different browser pop-up windows

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.