IE 6/7访问被拒绝尝试访问弹出窗口。文档 [英] IE 6/7 Access Denied trying to access a popup window.document

查看:100
本文介绍了IE 6/7访问被拒绝尝试访问弹出窗口。文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用window.open()创建一个没有URL源的弹出窗口。我不给它一个URL,因为我很快就要发表一个表单。然而,在此期间,我想显示一个简短的现在加载...消息,所以用户没有看到一个空白页面2-3秒,它将采取的形式发布通过。 / p>

我尝试添加只写入弹出窗口文档的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){}

//我们等待切换表单发送通过,显示一个简单的等待消息
$ j(wref.document.body).html('现在加载…'); // EPIC FAIL
wref.focus();


解决方案

  a href =#onclick =return test();> Test< / a> 
< script type =text / javascript>
function test(){
window.open('javascript:opener.write(window);','_name','width = 200,height = 200'
}
函数write(w){
w.document.write(Hello,World);
}
< / script>

适用于IE 6,7& 8,Opera 9.6,Firefox 2& 3.
在Windows 3和Safari 3的Safari中不起作用4或Google Chrome。



当它工作时,它会导致位置框中的一个非常丑的URL。



如果上面列出的浏览器支持是可以接受的,您可以使用提供的解决方案,否则我会做大卫说的话和 window.open('Loading.htm'...)其中 Loading.htm 包含您要显示的任何内容(您应该保持轻量级,否则加载和渲染可能需要更长时间才能使表单将POST) 。


I'm creating a popup window with no URL source using window.open(). I don't give it a URL because soon I'll want to post a form to it. However, in the meantime I'd like to display a short "Now loading..." message so the user isn't looking at a blank page for the 2-3 seconds it'll take the form post to go through.

I tried adding Javascript that just writes to the popup window's document. That worked great in Firefox and IE 8, but failed with an Access Denied message in IE 6 and 7. Anyone know of a way around this? I would love to be able to a) hard-code some HTML into window.open(), b) learn how to update the popup's DOM in this situation, or c) hear about anything anyone can think of.

Below is the code I'm using to spawn the window:

    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 &#133;'); // EPIC FAIL
        wref.focus();

解决方案

<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>

Works in IE 6, 7 & 8, Opera 9.6, Firefox 2 & 3. Does not work in Safari for Windows 3 & 4 or Google Chrome.

When it does work, it results in a pretty ugly URL in the Location box.

If the browser support listed above is acceptable, you can use the solution provided, otherwise I'd do what David said and window.open('Loading.htm' ...) where Loading.htm contains whatever content you want to display (you should probably keep it lightweight otherwise it might take longer to load and render than the form will to POST).

这篇关于IE 6/7访问被拒绝尝试访问弹出窗口。文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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