选项卡式网站中的 window.location
我正在处理一个使用选项卡的网站。外部选项卡是 facebook.com。内部选项卡是 Facebook 应用程序。
当我运行以下函数时:
$(document).ready(function() {
// to show it in an alert window
alert(window.location);
// to store it in a variable
var loc = window.location;
});
返回的值是内部选项卡的 url,即主机。有没有办法使用 JQuery 函数生成外部选项卡的 url?
I'm dealing with a website that uses tabs. The outer tab, is facebook.com. The inner tab is a facebook application.
When I run the following function:
$(document).ready(function() {
// to show it in an alert window
alert(window.location);
// to store it in a variable
var loc = window.location;
});
The returned value is the url of the inner tab, the host. Is there a way to produce the url of the outer tab using a JQuery function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许您正在寻找
parent
:Maybe you're looking for
parent
:我猜你的页面是使用 Iframe 显示的?在这种情况下,由于同源策略限制,您无法对父级执行任何操作。更多信息请访问:http://en.wikipedia.org/wiki/Same_origin_policy。
如果内部和外部选项卡位于同一域,请使用:
请注意,如果页面 URL 为“blah.facebook.com”且 facebook 应用程序加载自,则上述 JavaScript 语句将不起作用'foo.facebook.com'。
I guess your page is displayed using Iframes? In that case, you cannot do anything with the parent due to Same Origin Policy restriction. More info can be found on: http://en.wikipedia.org/wiki/Same_origin_policy.
If inner and outer tab are on same domain, use:
Please note that above JavaScript statement won't work in case page url is for instance 'blah.facebook.com' and the facebook application is load from 'foo.facebook.com'.
这是跨站点脚本的问题,这是不可能的。
“域、协议和端口必须匹配。”
This is an issue of cross site scripting and this isn't possible.
"Domains, protocols and ports must match."