我不知道当我在html中添加js时弹出窗口无法自动弹出的原因是什么,js将检查数据以获得“错误”/“过期”并将弹出全屏消息,任何人都可以帮助?
这是popup js:
(function ($) {
$(function () {
$.get("http://www.theonionism.com/webcontrol/check.php?client=www.theonionism.com", function(data){
console.log(data);
if(data == "error"){
alert("Web site error, please contact us");
return false;
}
if(data == "expired"){
$("body").append('<div class="expried-background"></div><div class="expried-nav">Website already expired, please contact us to resolve the matter.</div>');
$("body").css("margin", "0px");
$(".expried-background").css({
"position":"absolute",
"top":"0px",
"left":"0px",
"background-color":"black",
"opacity": "0.8",
"z-index": "99999",
"width": $(document).width(),
"height": $(document).height()
});
$(".expried-nav").css({
"position":"absolute",
"top": "45%",
"height":"40px",
"width":"100%",
"background-color":"#fff",
"z-index": "999999",
"font-family":"Arial",
"font-weight":"bold",
"text-align":"center",
"color":"red",
"padding-top":"20px",
});
return false;
}
});
});
})(jQuery);
答案 0 :(得分:0)
尝试使用:
尝试使用外部
function($){}() // remove it and try
$(function(){
// put your stuff here
});
答案 1 :(得分:0)
您好我本地尝试了这个并且它按您需要的方式工作:
$(function () {
$.get("http://localhost/jq/1.php?client=www.get.com", function(data){
if(data == "err"){
alert("Data Loaded: " + data);
$("body").append('<div class="expried-background"></div><div class="expried-nav">'+data+'Website already expired, please contact us to resolve the matter.</div>');
$("body").css("margin", "0px");
$(".expried-background").css({
"position":"absolute",
"top":"0px",
"left":"0px",
"background-color":"black",
"opacity": "0.8",
"z-index": "99999",
"width": $(document).width(),
"height": $(document).height()
});
$(".expried-nav").css({
"position":"absolute",
"top": "45%",
"height":"40px",
"width":"100%",
"background-color":"#fff",
"z-index": "999999",
"font-family":"Arial",
"font-weight":"bold",
"text-align":"center",
"color":"red",
"padding-top":"20px"
});
return false;
}
});
});
答案 2 :(得分:0)
你试过这种方式:
if(data == '("error");'){
// do your stuff in case of error
}
and
if(data == '("expired");'){
// do your stuff in case of expiration
}
如果这解决了问题,请告诉我。 并且请不要忘记接受它作为答案。
由于