The Web JS alert pop-up box, sometimes not what we want, but sometimes want to give users a friendly hint, look at the Android Toast hint box can also be implemented on the Web front-end, the following is a reference to a person's source code slightly modified to do
JavaScript Document//Prompt message function warn (msg,opt,left,top) {if (opt) {var obj = $ ("#" +opt);
New Toast ({context:$ (' body '), message:msg},obj,left,top). Show ();
var Toast = function (config,obj,left,top) {this.context = config.context==null?$ (' body '): config.context;//context This.message = config.message;//Display Content this.time = config.time==null?3000:config.time;//Duration This.left = config.left;//
Distance from the left side of the container this.top = (SCREEN.AVAILHEIGHT/4) *3;//distance from the top of the container if (obj) {this.left = Obj.offset (). Left Plus left;
This.top = Obj.offset (). Top + top;
} this.init ();
} var msgentity;
Toast.prototype = {//Initialize the displayed location content Init:function () {$ ("#toastMessage"). Remove ();
Set the message body var msgdiv = new Array ();
Msgdiv.push (' <div id= ' Toastmessage ">");
Msgdiv.push (' <span> ' +this.message+ ' </span> ');
Msgdiv.push (' </div> ');
Msgentity = $ (Msgdiv.join (')). Appendto (This.context); Set Message style var left = This.left = = null? This.context.width ()/2-msgentity.find (' span ').width ()/2:this.left; var top = This.top = null?
' 20px ': this.top; Msgentity.css ({position: ' absolute ', top:top, ' z-index ': ' The ', Left:left, ' background-color ': ' Black ', Color: ' White ', ' Font-size ': ' 12px ', padding: ' 5px ', margin: ' 5px ', ' Border-radius ': ' 4px ', '-moz-border-radius ': ' 4px ', '-
Webkit-border-radius ': ' 4px ', opacity: ' 0.5 ', ' font-family ': ' Microsoft Ya-hei '};
Msgentity.addclass (". Toast");
Msgentity.hide ();
},///Show Animation show:function () {Msgentity.fadein (THIS.TIME/2);
Msgentity.fadeout (THIS.TIME/2); }
}