用Jquery重写windows.alert方法实现思路
已经在 ie8 , firefox3.0.11下面测试通过
. 代码如下:
$.extend({
includepath: '',
include: function(file)
{
var files = typeof file == "string" ? [file] : file;
for (var i = 0; i < files.length; i++)
{
var name = files[i].replace(/^\s|\s$/g, "");
var att = name.split('.');
var ext = att[att.length - 1].tolowercase();
var iscss = ext == "css";
var tag = iscss ? "link" : "script";
var attr = iscss ? " type='text/css' rel='stylesheet' " : " language='javascript' type='text/javascript' ";
var link = (iscss ? "href" : "src") + "='" + $.includepath + name + "'";
if ($(tag + "[" + link + "]").length == 0) document.write("<" + tag + attr + link + "></" + tag + ">");
}
}
});
$.include(['script/jquery.pbox.js','/css/pop_win.css']);
$(document).ready(function()
{
var isfirstalert = true;
var alertqueue = [];
window.alert = showalert;
var palert = "";
palert += "<p style=\"width:380px; height:180px; overflow:hidden;display:none\" id=\"palert\">";
palert += " <p class=\"win_c\">";
palert += " <p class=\"win_t\" id=\"\">";
palert += " <p class=\"mail_timg\" ><h3>title<\/h3><\/p>";
palert += " <p class=\"clear\"><\/p>";
palert += " <\/p>";
palert += " <p class=\"alrt2\" style=\"text-align:center\">";
palert += " <span id=\"spaalertmessage\" class=\"f14 ifont\"><\/span><br \/>";
palert += " <p class=\"clear\"><\/p>";
palert += " <\/p>";
palert += " <p class=\"acenter\"><input id='alertclose' type=\"button\" value=\"确定\" class=\"btn7\" \/> <input type=\"reset\" value=\"取消\" style=\"display:none\" class=\"btn8\" \/><br \/><br \/><\/p>";
palert += " <p> <\/p>";
palert += " <\/p>";
palert += " ";
palert += "<\/p>";
$("body").append(palert);
function showalert(info)
{
alertqueue.push(info);
if (isfirstalert)
{
isfirstalert = false;
openalert();
}
}
$("#alertclose").click(function()
{
$('#palert').closediv()
if (alertqueue.length > 0)
{
settimeout(openalert, 150);
}
});
function openalert()
{
$("#spaalertmessage").html(alertqueue[0]);
alertqueue.splice(0, 1);
$("#palert").opendiv();
}
});
注:以上引用js与css的jquery插件
推荐阅读
-
用Jquery重写windows.alert方法实现思路
-
jQuery用noConflict代替$的实现方法
-
用JQuery实现全选与取消的两种简单方法
-
asp.net下用url重写URLReWriter实现任意二级域名的方法第1/2页
-
用原生JavaScript实现jQuery的$.getJSON的解决方法
-
Jquery post传递数组方法实现思路及代码
-
用jquery存取照片的具体实现方法
-
jquery用get实现ajax在ie里面刷新不进入后台解决方法
-
asp.net下用url重写URLReWriter实现任意二级域名的方法第1/2页
-
用Jquery重写windows.alert方法实现思路