0

我正在使用以下代码显示弹出窗口:

function validatePlaces()
{
    $(document).ready(function(){
        //open popup
        $("#pop").ready(function(){
            $("#overlay_form").fadeIn(1000);
            positionPopup();
        });

        //close popup
        $("#close").click(function(){
            $("#overlay_form").fadeOut(4500);
        });
    });

    //position the popup at the center of the page
    function positionPopup()
    {
        if(!$("#overlay_form").is(':visible'))
        {
            return;
        }
        $("#overlay_form").css({
            left: ($(window).width() - $('#overlay_form').width()) / 2,
            top: ($(window).width() - $('#overlay_form').width()) / 7,
            position:'absolute'
        });
    }
    //maintain the popup at center of the page when browser resized
    $(window).bind('resize',positionPopup);


    var placeValue = document.getElementById("form1:placeId").value;
    var countryValue = document.getElementById("form1:countryId").value;
    var continentValue = document.getElementById("form1:continentId").value;

    if(placeValue=="Name Of Places?"||placeValue==" ")
    {
        //alert("Please enter your search place name... ");
        pop(); 
        return false;
    }


    return true;
}

问题:页面自动刷新,弹出窗口很快消失,所以我需要设置一个 setTimeout。或者,如果有任何其他解决方案,请提供。请帮忙...

页面正在自动刷新..我不知道为什么..

使用的弹出表单代码:

<form id="overlay_form" style="display:none; opacity:0.8; background-color: gray; border-
    radius:10px; height:65px; margin-top: 12%; width:350px;"> 
    <img border="0" src="../../resources/images/error.png" alt="" width="30" height="22"/> 
    <p style="font-family:times new roman ; font-size:18px; color: white;"> 
       Enter your search place name...</p> 
    <a href="#" id="close" style="color: black;"><b>Close</b></a> 
</form>
4

2 回答 2

0

我在使用 List.js 时遇到了一个非常相似的问题,即在单击排序后立即刷新页面。几个小时后,我尝试将表单元素更改为 div 并修复了它。我认为它的行为就好像它被提交了一样。我知道它很晚,但任何其他人请尝试将表单更改为 div。它将停止页面刷新。

于 2014-11-04T04:03:41.000 回答
-1
//5000 is the time in mili seconds after which you want to hide the popup
$("#overlay_form").fadeIn(1000).delay(5000).fadeOut(1000);
于 2013-06-04T07:15:53.627 回答