window.opener.location.href在IE中可用,但不适用于Chrome或Safari [英] window.opener.location.href works in IE but not Chrome or Safari

查看:1278
本文介绍了window.opener.location.href在IE中可用,但不适用于Chrome或Safari的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究这个问题,虽然在各种论坛上有很多关于类似问题的帖子,但没有一个问题或解决方案完全符合我的要求。

我有应用程序已成功使用下面的功能,在弹出窗口完成后,重定向回父窗口。最近,我一直在研究与其他浏览器的兼容性(以便系统可以通过iPad使用),并发现使用Safari或Chrome时此功能存在问题。



<父页面是一些数据库信息的摘要,用户点击链接打开一个窗口(通过window.open)来查看更详细的数据。完成后,在子窗口上有一个链接,用于刷新父级数据(部分是为了确保在您返回父级时显示正确的数据)并关闭子级。



Safari中的控制台报告window.opener.location.href'的结果不是函数。我试图使用上面的'window.opener.document.location.href'和'window.opener.window.location.href'(从网上提供的其他解决方案中获取),但没有成功。



我知道有些人有这个功能,但其他人有这种问题。

以下是我的功能:

 函数quicklink(url){
window.opener.document.location.href(url);
self.close();
}

这对IE7,8和9的第一天起作用,但没有在Safari(适用于Windows或iPad)或Chrome中工作。

div>

href 是一个属性,而不是方法。只需指定URL即可:

  window.opener.document.location.href = url; 

这也适用于IE。它也是一个属性,即使它允许您将它用作方法。


I have been researching this problem and while there's lots of posts on various forums about similar problems, none of the problems or solutions exactly match mine.

I have an application that has been successfully using the function below to redirect back to the parent window once finished with a popup. Recently I have been investigating compatibility with other browsers (to allow the system to be used via iPad) and have found that there is a problem with this function when using Safari or Chrome.

The parent page is a summary of some databased info, and the user clicks a link to open a window (via window.open) to view more detailed data. When finished there is a link on the child window that refreshes the data on the parent (partly to ensure the correct data is displayed when you return to the parent) and closes the child.

The Console in Safari reports "the result of 'window.opener.location.href' is not a function". I have tried to use the above and 'window.opener.document.location.href' and 'window.opener.window.location.href' (taken from other solutions offered up on the net) but with no success.

I know that some people have this function working well, while others have this sort of problem. I'm wondering if there are any answers to this specific situation.

Here is my function:

function quicklink(url) {
window.opener.document.location.href(url);
self.close();
}

This has worked from day one on IE7,8 and 9 but doesn't work in Safari (for windows or iPad) or Chrome.

Any ideas?

解决方案

href is a property, not a method. Just assign the URL to it:

window.opener.document.location.href = url;

This will work in IE also. It's a property there too, even if it lets you use it as a method.

这篇关于window.opener.location.href在IE中可用,但不适用于Chrome或Safari的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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