jod*_*ell 3 javascript internet-explorer dom
我正在使用window.open()创建一个没有URL源的弹出窗口.我没有给它一个URL,因为我很快就要发表一个表格了.但是,与此同时,我想显示一个简短的"正在加载..."消息,这样用户就不会在2-3秒内查看空白页面,它将通过表单发布.
我尝试添加只写入弹出窗口文档的Javascript.这在Firefox和IE 8中运行良好,但在IE 6和7中因访问拒绝消息而失败.任何人都知道这方面的方法吗?我希望能够a)将一些HTML硬编码到window.open(),b)学习如何在这种情况下更新弹出窗口的DOM,或者c)听到任何人都能想到的任何东西.
下面是我用来生成窗口的代码:
var wref = window.open("", winName, "toolbar=1,resizable=1,menubar=1,location=1,status=1,scrollbars=1,width=800,height=600");
if (wref != null) {
try {wref.opener = self;} catch (exc) {}
// while we wait for the handoff form post to go through, display a simple wait message
$j(wref.document.body).html('Now loading …'); // EPIC FAIL
wref.focus();
Run Code Online (Sandbox Code Playgroud)
<a href="#" onclick="return test();">Test</a>
<script type="text/javascript">
function test() {
window.open('javascript:opener.write(window);', '_name', 'width=200,height=200');
}
function write(w) {
w.document.write("Hello, World.");
}
</script>
Run Code Online (Sandbox Code Playgroud)
适用于IE 6,7和8,Opera 9.6,Firefox 2和3.在Safari for Windows 3&4或Google Chrome中无效.
当它工作时,它会在"位置"框中产生一个非常难看的URL.
如果上面列出的浏览器支持是可以接受的,你可以使用提供的解决方案,否则我会做David所说的内容,window.open('Loading.htm' ...)其中Loading.htm包含你要显示的任何内容(你应该保持它的轻量级,否则加载和渲染可能需要更长的时间)表格将POST).
| 归档时间: |
|
| 查看次数: |
14271 次 |
| 最近记录: |