当scanStatus == 'limit'
centerPopup()
和loadPopup()
函数未触发时。
从名为js/count.js
的文件中调用这些函数。该文件可用here。
这些是我的函数,存储在js/popup.js
:
// Loading popup with jQuery magic!
function loadPopup() {
// Loads popup only if it is disabled
if (popupStatus == 0) {
$("#backgroundPopup").css({
"opacity": "0.7"
});
$("#backgroundPopup").fadeIn("slow");
$("#popupContact").fadeIn("slow");
popupStatus = 1;
}
}
// Centering popup
function centerPopup() {
// Request data for centering
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#popupContact").height();
var popupWidth = $("#popupContact").width();
// Centering
$("#popupContact").css({
"position": "absolute",
"top": windowHeight / 2 - popupHeight / 2,
"left": windowWidth / 2 - popupWidth / 2
});
// Only need force for IE6
$("#backgroundPopup").css({
"height": windowHeight
});
}
这两个文件都包含在HTML中,如下所示:
<script type="text/javascript">
var uid = "rZCENk6w";
var website = "http://www.engadget.com";
</script>
<script type="text/javascript" src="js/popup.js"></script>
<script type="text/javascript" src="js/count.js"></script>
提前感谢您的帮助。
答案 0 :(得分:4)
基于代码found in the linked file (near the bottom),方法永远不会在文档准备就绪时被调用,因为它们被注释掉了:
//if (scanStatus == 'limit') {
//LOADING POPUP
//Click the button event!
//$("#button").click(function(){
//centering with css
//centerPopup();
//load popup
//loadPopup();
//});}
您需要取消注释它们才能相应地执行它们:
if (scanStatus == 'limit') {
$("#button").click(function() {
centerPopup();
loadPopup();
});
}