繁体   English   中英

灯箱,用于使用javascript重定向

[英]lightbox for redirect using javascript

我打算在印度语中启动我的网站,并且我计划在打开网站时,灯箱应该要求选择语言并进行相应的重定向。 我正在使用以下代码:

<html>
<title>Test</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>
$(document).ready(function() {  
    var id = '#dialog';

    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    //Set heigth and width to mask to fill up the whole screen
    $('#mask').css({'width':maskWidth,'height':maskHeight});

    //transition effect
    $('#mask').fadeIn(500); 
    $('#mask').fadeTo("slow",0.9);  

    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();

    //Set the popup window to center
    $(id).css('top',  winH/2-$(id).height()/2);
    $(id).css('left', winW/2-$(id).width()/2);

    //transition effect
    $(id).fadeIn(2000);     

    //if close button is clicked
    $('.window .close').click(function (e) {
        //Cancel the link behavior
        e.preventDefault();
        $('#mask').hide();
        $('.window').hide();
    });

    //if mask is clicked
    $('#mask').click(function () {
        $(this).hide();
        $('.window').hide();
    });
});
</script>

<style>
#mask {
position: absolute;
left: 0;
top: 0;
z-index: 9000;
background-color: #000;
display: none;
}

#boxes .window {
position: absolute;
left: 0;
top: 0;
width: 440px;
height: 200px;
display: none;
z-index: 9999;
padding: 20px;
border-radius: 15px;
text-align: center;
}

#boxes #dialog {
width: 720px;
height: 320px;
padding: 10px;
background-color: #ffffff;
font-family: Helvetica, 'Segoe UI Light', sans-serif;
font-size: 15pt;
}

#popupfoot {
font-size: 11pt;
position: absolute;
bottom: 0px;
width: 250px;
left: 250px;
padding-bottom:5px;
}
</style>
</head>

<body><div id="boxes">
<div id="dialog" class="window">
<h1>CHOOSE YOUR LANGUAGE</h1>
<a href="http://www.vashikaranguruji.com" target="_blank"><h2>ENGLISH            </h2></a>
<a href="http://www.vashikaranguruji.com/h" target="_blank"><h2>HINDI</h2></a>
<div id="popupfoot"><a href="#" class="close agree">Close</a></div>
</div>
<div id="mask"></div>
</div>
<div>
<h1> This is hidden Part </h1>
</div>

</body>
</html>
  1. 这对我来说很好用,但是当我在灯箱外部单击时,灯箱消失了。 我想要如果我在灯箱外面单击,它应该不会消失。 我该怎么办?
  2. 其次,我想单击按钮以更改语言,应再次打开该对话框。 我不知道该怎么做。 有什么建议么?

1)删除遮罩单击事件,然后在外部单击时弹出窗口不会消失。

2)制作一个显示弹出窗口的功能。

<script>

function showLanguageSelectionModal(){
var id = '#dialog';

//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();

//Set heigth and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});

//transition effect
$('#mask').fadeIn(500); 
$('#mask').fadeTo("slow",0.9);  

//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();

//Set the popup window to center
$(id).css('top',  winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);

//transition effect
$(id).fadeIn(2000);   
}


$(document).ready(function() {  
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();

$('#mask').hide();
$('.window').hide();
});

 showLanguageSelectionModal();

});
</script>

的HTML

<button onclick="showLanguageSelectionModal();">Select Language</button>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM