使用DOM和* no * html src创建弹出窗口 [英] Creating popup using DOM and *no* html src
问题描述
大家好,
我有一个带有弹出窗口的网络应用程序,用于输入数据。每次打开此窗口时我都不希望
访问网页,因为大多数应用程序
都是AJAX。但我无法弄清楚如何打开一个新窗口并用DOM构建它,而不是必须提供一个src。即使是一个blank.html作为src
也需要时间来获取。
如何创建弹出窗口并动态添加DOM内容而无需任何
html是什么?
Hi all,
I have a web app with a popup window for entering data. I don''t want
to access the web every time this window is opened, as most of the app
is AJAX. But I can''t figure out how to open a new window and build it
with DOM rather than having to provide a src. Even a blank.html as src
takes time to fetch.
How can I create a popup and dynamically add DOM content without any
html at all?
推荐答案
jonathon写道:
jonathon wrote:
如何创建一个弹出窗口动态添加DOM内容而不用任何
html?
How can I create a popup and dynamically add DOM content without any
html at all?
不幸的是,你不能。当你打开一个窗口时,它必须有一个网址。
解决方法是使用about :blank的网址,但是这个导致安全
安全网站上的警告,并且在某些浏览器中不起作用。您可以使用
javascript :伪协议来写出虚拟内容,但在某些情况下,这也会引发安全警告
。您可以留下一个空白网址,但只有一些
浏览器比 更喜欢这个:空白。
这是,IMO,不幸的。应该有一个跨浏览器的方式来弹出一个
的新窗口并用内容填充它,没有任何安全问题或问题。
如果有人知道一个解决方案,我会_love_知道它。
-
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Unfortunately, you can''t. When you open a window, it must have a url.
A work-around is to use the url of "about:blank", but this causes security
warnings on secure sites, and doesn''t work in some browsers. You can use a
javascript: pseudo-protocol to write out dummy content, but this also throws
up security warnings in some cases. You can leave a blank url, but only some
browsers prefer this over about:blank.
This is, IMO, unfortunate. There should be a cross-browser way to pop up a
new window and fill it with content without any security issues or problems.
If anyone knows of a solution, I would _love_ to know it.
--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
我不熟悉ajax,所以我不知道是否这是一个看似合理的
解决方案:
但我能想到的唯一其他想法是实际制作
弹出窗口作为隐藏的div元素内的内容。然后在
某些事件中你可以看到它,并且使用z-index样式你可以将
定位在其他内容之上。
我不知道这是否是一个可以接受的风险,但是它可以模仿弹出窗口。没有实际需要
提供一个窗口的URL.open();
I am not familiar with ajax, so I don''t know if this is a plausible
solution:
But the only other idea I would be able to think of is to actually make
the "popup" as content inside a div element which is hidden. Then on
some event you make it visible, and using z-index style you can then
position it above the other content.
I don''t know if this is an acceptable avenue to venture down, but it
would be a possible way to mimic a "popup" without actually having to
supply an url for a window.open();
Matt Kruse写道:
Matt Kruse wrote:
jonathon写道:
jonathon wrote:
如何在没有任何
html的情况下创建弹出窗口并动态添加DOM内容?
How can I create a popup and dynamically add DOM content without any
html at all?
不幸的是,你不能。当你打开一个窗口时,它必须有一个网址。
Unfortunately, you can''t. When you open a window, it must have a url.
实际上,我找到了一个你可以做到这一点的网站。
http://oit.wvu.edu/support/ training / ... OM / calvin.html
''Reader()''函数打开一个弹出窗口,没有任何src和write()'s
内容作为新窗口的字符串。但是我的窗口比这个更复杂了一些,并且不适合这种方法。
特别是因为它使用了iframe。
Actually, I found a site where you can do this.
http://oit.wvu.edu/support/training/...OM/calvin.html
The ''Reader()'' function opens a popup without any src and write()''s
content as a string to the new window. But my window is just a bit
more complex than this one, and doesn''t lend itself to this approach.
Especially since it uses iframes.
这篇关于使用DOM和* no * html src创建弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!