弹出窗口javascript(如何将焦点添加到弹出窗口)
如何添加焦点弹出窗口在这个代码请帮助我有人弹出窗口javascript(如何将焦点添加到弹出窗口),javascript,jquery,popup,Javascript,Jquery,Popup,如何添加焦点弹出窗口在这个代码请帮助我有人 <script> $(document).ready(function() { //select all the a tag with name equal to modal $('a[name=modal]').click(function(e) { //Cancel the link behavior e.preventDefault(); //Get the
<script>
$(document).ready(function() {
//select all the a tag with name equal to modal
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $(this).attr('href');
//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(10);
$('#mask').fadeTo("fast",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/8-$(id).height()/2);
$(id).css('left', winW/2.5-$(id).width()/2);
//transition effect
$(id).fadeIn(100);
});
//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>
$(文档).ready(函数(){
//选择名称等于modal的所有标记
$('a[name=modal]')。单击(函数(e){
//取消链接行为
e、 预防默认值();
//拿到A标签
var id=$(this.attr('href');
//获取屏幕的高度和宽度
var maskHeight=$(document.height();
var maskWidth=$(window.width();
//设置遮罩的高度和宽度以填充整个屏幕
$('#mask').css({'width':maskWidth,'height':maskHeight});
//过渡效应
$('面具').fadeIn(10);
$(#mask').fadeTo(“fast”,0.8);
//获取窗口的高度和宽度
var winH=$(window.height();
var winW=$(window.width();
//将弹出窗口设置为居中
$(id).css('top',winH/8-$(id).height()/2);
$(id).css('left',winW/2.5-$(id).width()/2);
//过渡效应
美元(id).fadeIn(100);
});
//如果单击“关闭”按钮
$('.window.close')。单击(函数(e){
//取消链接行为
e、 预防默认值();
$(“#掩码”).hide();
$('.window').hide();
});
//如果单击了“遮罩”
$(“#掩码”)。单击(函数(){
$(this.hide();
$('.window').hide();
});
});
我想你的问题在于你期望这一行
var id = $(this).attr('href');
为您提供窗口
或
的引用(如果是div,您的代码几乎可以理解),并且div是一个覆盖(不是弹出窗口)
我认为您需要找到创建覆盖的代码,然后您可以在div中的一个字段上找到“…”和“…”。在哪里创建弹出窗口?我没有看到window.open()。没有看到在代码中创建任何弹出窗口。。。。。