function Salert (msg,boxtype,func,msgtitle)
Salert (' Information content ', 1, ', ' Information title ')
@msg: Prompt For information content
@boxtype: 1 for Pop-up box, 2 for Confirmation box, 3 for Prompt box
@func: Functions performed when a point is confirmed
@title: Information box title text content
Only MSG is required, and the following parameters can be omitted. If the middle argument is empty, it is represented in the corresponding position ' or ' (single double quotation marks are chosen according to the actual situation)
Calling this method requires the following code to be added to the head area of each page used.
Copy Code code as follows:
<script type= "Text/javascript" src= "Alert1/alert.js" src= "Alert1/alert.js" ></script>
<link href= "Alert1/alert.css" href= "Alert1/alert.css" rel= "stylesheet" type= "Text/css"/>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "xml:lang=" ZH-CN "lang=" ZH-CN "> <pead> <title> ; pop-up test page </title> <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/> <meta http-equiv=" content-language "content=" gb2312 "/> <style type=" t Ext/css "><!--/*<!--[cdata[*/*{margin:0;padding:0; UL Li{list-style-type:none;} html,body{height:100%;} #textid {padding:10px} #bgDiv {position:absolute;top:0;left:0;width:100%;height:100%;background: #000; Filter:alpha (opacity:75); opacity:0.6;} #msgDiv {text-align:center;position:absolute;left:50%;top:50%;line-height:25px;z-index:101; padding:1px 0 25px;font-size:12px;height:auto!important;height:142px;min-height:142px; Width:255px;background:url (attachments/month_0904/g200942816344.gif) left top repeat-y #msgTxt {clear:both;padding:10px 10px;text-align:left;} #msgTxt li{border-bottom:1px dotted #69a;} #msgTitle {font-size:12px;margin:0;height:21px;width:100%;line-height:20px;text-indent:3em; Background:url (attachments/month_0904/n200942816339.gif) left top no-repeat;text-align:left; Filter:alpha (opacity:75); opacity:0.6;font-family:verdana,arial;} #msgTitle B{cursor:pointer;float:right;width:30px;height:20px;margin-right:10px;display:inline;} #msgButton input{border:1px solid #369; color: #000; background: #eef5ff; cursor:pointer; font-size:12px;height:20px;padding:0 5px;line-height:20px;margin:0 5px;} #msgButton {position:absolute;bottom:0px;left:0;width:255px;text-align:center;height:20px;padding:8px 0 6px; Background:url (Attachments/month_0904/l200942816354.gif) Left top repeat-y;} #msgRun {width:600px;margin:0 auto;padding:10px;background: #fff5ee; border:1px solid #f80;} #msgRun ul{margin:10px;padding:10px;background: #fff; border:1px solid #f85; font-size:12px;} #msgRun ul li{border-bottom:1px dotted #ccc; line-height:25px;} input {cursor:pointer;} p{padding:5px;} textarea{width:580px;overflow:hidden;height:60px;padding:5px;} /*]]>*/--></style> <script type= "text/javascript" ><!--function $t (s) { return Document.all?document.all[s]:d Ocument.getelementbyid (s); }//Pop-up functions function Salert (msg,boxtype,func,msgtitle) {if ($t (' Msgdiv ')) return; if ($t (' Bgdiv ')) {$t (' Bgdiv '). style.display= "Block"; }else{var bgobj=document.createelement ("div"); Bgobj.setattribute (' id ', ' bgdiv '); Document.body.appendChild (Bgobj); if (!window. XMLHttpRequest) {var fRm=document.createelement ("iframe"); Frm.setattribute ("name", "Completionframe"); Frm.setattribute ("id", "completionframe"); Bgobj.appendchild (frm);} var msgobj=document.createelement ("div") Msgobj.setattribute ("id", "msgdiv"); MsgObj.style.marginLeft = " -127px"; MsgObj.style.marginTop = -145+document.documentelement.scrolltop+ "px";; var title=document.createelement ("H4"); Title.setattribute ("id", "msgtitle"); var closemsg=document.createelement ("B"); var titlespan=document.createelement ("span"); if (msgtitle) Titlespan.innerhtml=msgtitle; Closemsg.onclick=function () {msg_close (); var txt=document.createelement ("div"); Txt.setattribute ("id", "msgtxt"); var msgbutton=document.createelement ("H5"); Msgbutton.setattribute ("id", "Msgbutton"); Document.body.appendChild (Msgobj); $t ("Msgdiv"). AppENdchild (title); $t ("Msgdiv"). appendchild (TXT); $t ("Msgdiv"). AppendChild (Msgbutton); $t ("Msgtitle"). AppendChild (CLOSEMSG); $t ("Msgtitle"). AppendChild (Titlespan); var confirm=document.createelement ("input"); Confirm.setattribute ("id", "msgconfirm"); Confirm.setattribute ("Type", "button"); Confirm.setattribute ("Value", "confirmation"); Confirm.onclick=function () {msg_close (); Eval (func); var cancel=document.createelement ("input"); Cancel.setattribute ("id", "msgcancel"); Cancel.setattribute ("Type", "button"); Cancel.setattribute ("value", "cancellation"); Cancel.onclick=function () {msg_close (); Switch (Boxtype * 1) {case 1:txt.innerhtml = msg; $t ("Msgbutton"). AppendChild (Confirm); Break Case 2:txt.innerhtml = msg; $t ("Msgbutton"). AppendChild (Confirm); $t ("MsgbuttoN "). appendchild (Cancel); Break Case 3:txt.innerhtml = msg; $t ("Msgbutton"). AppendChild (Confirm); Break Default:txt.innerHTML = msg; $t ("Msgbutton"). AppendChild (Confirm); Break The function Msg_close () {$t ("Bgdiv"). style.display= "None"; var msgobj= $t ("Msgdiv"); var title= $t ("Msgtitle"); if (msgobj) $t ("Msgdiv"). RemoveChild (title); Document.body.removeChild (Msgobj); Window.onload=function () {$t ("RunCode"). Onclick=function () {var code= $t ("code"). InnerHTML; eval (code); }//--></script> </pead> <body> <div id= "Msgrun" > <div> <p > Pet Information Box instance:</p> <input type= "button" value= pop-up box "onclick=" salert (' Test effect 2 ', 1); "/> <input type= button" value= "Confirmation Box" onclick= "Salert" (' Confirmation box ', 2, ', ' Spoil my Baby '); "/> <input type=" button "value=" Prompt Box "onclick=" Salert (' cue box '); "/> </div> <p>function Salert (msg,boxtype,func,title) </p> <ul> <l I >salert (' information content ', 1, ', ' Information title ') </li> <li > @msg: Hint message content </li> <li > @boxtype: 1 for Pop-up box, 2 for confirmation box, 3 for Prompt box </li> <li > @func: Function executed when point confirmation </li> <li > @title: Message box title text content </li> <li ; only msg is required, and the following parameters can be omitted. If the middle parameter is null, the corresponding position ' or ' ' means (select single double quotes according to the actual situation) </li> <li > Call this method to add the following code to the head area of each page used. </li> </ul> <textarea rows= "5" cols= ", > <script type=" text/javascript "src=" Alert1 /alert.js "src=" alert1/alert.js "></script> <link href=" alert1/alert.css "href=" Alert1/alert.css "rel=" Stylesheet "type=" Text/css "/>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Test environment: You can test the Format function as required in the following text box:
Copy Code code as follows:
Salert (' Information content ', 1, ' location.href= ' http://www.jb51.net ', ' Information title ')