我有弹出窗口的三个功能。只想逐个onload/refresh
打电话给他们
刷新弹出窗口更改告诉我解决方案我可以在每次刷新函数调用时使用此进程。但是下一次刷新下一个。我尝试使用数组和随机标记,但无法运行它。
<html>
<head>
<title>four popup ads js used</title>
<link type="text/css" rel="stylesheet" href="popup.css">
<script src="jquery-1.2.6.min.js" type="text/javascript"></script>
<script src="popup.js" type="text/javascript"></script>
<script type="text/javascript">
// Bottom Popup JS//
$(document).ready(function () {
// When site loaded, load the Popupbox First
loadPopupBox();
$('#popupBoxClose').click(function () {
unloadPopupBox();
});
$('#container').click(function () {
unloadPopupBox();
});
function unloadPopupBox() { // TO Unload the Popupbox
$('#popup_box').fadeOut("slow");
$("#container").css({ // this is just for style
"opacity": "1"
});
}
function loadPopupBox() { // To Load the Popupbox
$('#popup_box').fadeIn("slow");
$("#container").css({ // this is just for style
"opacity": "0.6"
});
}
});
// Transparent popup JS//
$(document).ready(function () {
$("p").click(function () {
$("#div1").fadeOut();
});
});
// onclick popup Under//
var win = null;
function NewWindow(mypage, myname, w, h, scroll, pos) {
if (pos == "random") {
LeftPosition = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100; TopPosition = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100;
}
if (pos == "center") {
LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100;
}
else if ((pos != "center" && pos != "random") || pos == null) { LeftPosition = 0; TopPosition = 20 }
settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes';
win = window.open(mypage, myname, settings);
}
</script>
</head>
<body>
<div id="div1" style="background-color:gray;height:650px;width:81%;position:relative;">
<div id="popup_box">
<div class="small_box">You May Like This <img src="close.jpeg" id="popupBoxClose" height=20 width=15></div>
<div>
<br>
<div style="float:left;border-right: 2px solid gray;"><a href=""><img src="slider-1.jpg" height=63><span style="float:right;"><br>IT's Only for U <br>Just click on it</span></a></div>
<div style="float:left;border-right: 2px solid gray;"><a href=""><img src="slider-2.jpg" height=63><span style="float:right;"><br>IT's Only for U <br>just click on it </span></a></div>
<div style="float:left;border-right: 2px solid gray;"><a href=""><img src="slider-2.jpg" height=63><span style="float:right;"><br>IT's Only for U <br>Just click on it </span></a></div>
<div style="float:left;"><a href=""><img src="slider-3.jpg" height=63><span style="float:right"><br>IT's Only for U <br>Just click on it</span></a></div>
</div>
</div>
</div>
</body>
</html>
我只想在刷新时逐一调用此pafe上的所有功能
答案 0 :(得分:0)
你可以这样使用。
HTML页面
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<link rel="stylesheet" href="StyleSheet.css">
</head>
<body>
<h4>Test Loaded</h4>
<div id="dialogA" class="box" title="Basic dialog">
<h1>dialogA</h1>
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<div id="dialogB" class="box" title="Basic dialog">
<h1>dialogB</h1>
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<div id="dialogC" class="box" title="Basic dialog">
<h1>dialogC</h1>
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<div id="dialogD" class="box" title="Basic dialog">
<h1>dialogD</h1>
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<script src="JavaScript.js" type="text/javascript"></script>
</body>
</html>
CSS文件 StyleSheet.css
#dialogA, #dialogB, #dialogC, #dialogD {
/*display: none;*/
}
.box {
display: none;
}
JavaScript文件 JavaScript.js
var textToShow = ['#dialogA', '#dialogB', '#dialogC', '#dialogD']; //add the div ID as an array
var resultID = textToShow[Math.floor(Math.random() * textToShow.length)]; //get the random Id from the array
//alert(resultID);//Debug the Div ID
loadPopup(resultID);//Pass the ID to the function
function loadPopup(resultID) {
switch(resultID) {
case '#dialogA':
//alert('#dialogA');//Debuging
$(resultID).dialog({ height: '100px', width: '20px' });//custom width and height
break;
case '#dialogB':
//alert('#dialogB');//Debuging
$(resultID).dialog({ height: '200px', width: '120px' });//custom width and height
break;
case '#dialogC':
//alert('#dialogC');//Debuging
$(resultID).dialog({ height: '300px', width: '220px' });//custom width and height
break;
case '#dialogD':
//alert('#dialogD');//Debuging
$(resultID).dialog({ height: '400px', width: '320px' });//custom width and height
break;
default:
//alert('default');//Debuging
$(resultID).dialog();//Default width and height will be reffer
}
}
如果你需要我的帮助。请通过搜索yeshansachithak
找到我的社交网络。