简体   繁体   English

DHTML模态窗口,在后台单击关闭

[英]DHTML modal window, close on background click

I am using the dhtml window widget script found here: 我正在使用在这里找到的dhtml窗口小部件脚本:

http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm

I would like for the user to be able to close the dhtml popup window when clicking the background. 我希望用户在单击背景时能够关闭dhtml弹出窗口。 Currently it only works when clicking the close button. 当前仅在单击关闭按钮时有效。 How do I add that to this script? 如何将其添加到此脚本中?

This is NOT for "dhtmlmodal" as the subject says. 如主题所述,这不是针对“ dhtmlmodal”的。 This is for "dhtmlwindow". 这是针对“ dhtmlwindow”的。 There IS a difference as "dhtmlmodal" does not even seem to have a .close() event, only a .hide() 有一个区别,因为“ dhtmlmodal”似乎没有.close()事件,只有.hide()

That widget is quite old now (over 6 years) and there are no doubt numerous newer, better alternatives, but that's besides the point. 该小部件现在已经很旧了(超过6年),毫无疑问,有许多更新更好的替代品,但是除此之外。

The documentation on the page you linked to details how to create the popup, and then how to access functions that act on the pop up. 您链接到的页面上的文档详细说明了如何创建弹出窗口,以及如何访问对弹出窗口起作用的功能。 Copied below for reference: 复制以下,以供参考:

Create links that manipulate an opened window in various ways when clicked on

<script type="text/javascript">
// this function invocation generates the popup with your specific parameters
// the variable name you assign (googlewin) is used to interact with the popup later
var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://google.com", "Google Web site", "width=700px,height=450px,resize=1,scrolling=1,center=1", "recal")
</script>

<!-- this is an example link that will call the close method on the googlewin object
this is the bit you need to apply to whatever it is that you want the visitor to be able to click on to close the popup -->
<a href="#" onClick="googlewin.close(); return false">Close Window</a>

Bear in mind that the widget you are using creates a popup window, not a true modal. 请记住,您使用的小部件会创建一个弹出窗口,而不是真正的模式。 If you were to use a modal (lightbox) you would have built in close functionality whenever the visitor clicked anywhere outside of the main modal content area. 如果要使用模式(灯箱),则只要访问者单击主要模式内容区域之外的任何位置,您都将内置关闭功能。

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

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