如何关闭DOM窗口jQuery? [英] How to close DOM Window jquery?

查看:136
本文介绍了如何关闭DOM窗口jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面提到的链接例3中
http://swip.codylindley.com/ DOMWindowDemo.html



您可以在窗口中添加一个链接来关闭它吗?

Window.close() self.close() parent.window.removechid() 不工作



我认为他们修改了 close() in jQuery.DOMwindow.js



Plz help。

解决方案

你必须使用> DOMwindow.js ,或者你可以做这样的事情吗?

  * {box-sizing:border-box; font-family:arial,helvetica,sans-serif;}#myModal {position:absolute;顶部:0;左:0;右:0;底部:0;文本对齐:中心;背景:黑色;不透明度:0.8;的z-index:999; / *确保此对话框覆盖所有其他* / display:none;}#modalInner {position:relative;顶部:10vh;高度:70vh;宽度:80vw; margin:0 auto;}#modalTop {position:absolute; top:0; left:0; overflow:hidden;} #mtL {float:left; height; height:20px; width:65vw; height :20px; width:10vw; text-align:center;} #x {width:20px; text-align:center; background:white; color:darkcyan;} #x:hover {background:darkcyan; color:white; cursor :指针;}#msg {position:relative; bottom:90px; width:50vw; margin:0 auto; color:white;}  

 < script src =https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js> ;< / script>< div id =myModal> < div id =modalInner> < div id =modalTop> < div id =mtL>< / div>< div id =mtR>< div id =x> x< / div>< / div> < / DIV> < iframe src =http://google.com>< / iframe> < div id =msg>这是一个IFRAME。 Google网页应显示在此处< / div> < / div>< / div>< div id =myButt> Click Me< / div> 

p>

In example 3 on the below mentioned link http://swip.codylindley.com/DOMWindowDemo.html

Can you add a link within the window to close it?

Window.close(), self.close() and parent.window.removechid() aren't working

I think they have modified the functionality of close() in jQuery.DOMwindow.js

Plz help.

解决方案

Do you have to use DOMwindow.js, or could you do something like this?

$('#myButt').click(function(){
  $('#myModal').fadeIn();
});

/* Close when user clicks on X, or on overlay: */
$('#x, #myModal').click(function(){
  $('#myModal').fadeOut();
});

* {box-sizing:border-box;font-family:arial,helvetica,sans-serif;}
#myModal{
  position:absolute;
  top:0;left:0;right:0;bottom:0;
  text-align:center;
  background:black;opacity:0.8;
  z-index:999; /* Ensure this dialog overlays all else */
  display:none;
}
#modalInner{
  position:relative;
  top:10vh;
  height:70vh;width:80vw;
  margin:0 auto;
}
#modalTop{position:absolute;top:0;left:0;overflow:hidden;}
  #mtL{float:left;height:20px;width:65vw;}
  #mtR{float:left;height:20px;width:10vw;text-align:center;}
    #x{width:20px;text-align:center;background:white;color:darkcyan;}
    #x:hover{background:darkcyan;color:white;cursor:pointer;}

#msg{position:relative;bottom:90px;width:50vw;margin:0 auto;color:white;}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<div id="myModal">
  <div id="modalInner">
    <div id="modalTop">
      <div id="mtL"></div><div id="mtR"><div id="x">x</div></div>
    </div>
    
    <iframe src="http://google.com"></iframe>
    
    <div id="msg">This is an IFRAME. Google webpage should appear in here</div>
  </div>
</div>
<div id="myButt">Click Me</div>

这篇关于如何关闭DOM窗口jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆