簡體   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