从 iframe 中打开链接
我会尽量保持简短。我有一个包含各个部分的页面。其中一个部分有一个 iframe,其中包含谷歌地图。在信息窗口上,我有一个链接,单击该链接时,我希望它在页面上的花式框中打开(不在 iframe 中......我可以做到这一点)。例如,如果我有一个链接说“google”,我喜欢它打开 http://www.google.co .uk/ 在 fancybox 中覆盖整个页面。
我有 2 个不同的页面和 2 个 JavaScript,1 个用于地图(iframe),另一个用于主页。该函数位于主页脚本中。
我认为我出错的地方是a)打开页面的正确调用b)将一个类附加到javascript,即class =“fancybox”。
我的地图信息窗口中有此链接(map.js):
<a href="javascript:parent.openSomething();">some content</a>
在我的 main.js 中:
function openSomething() {
//this is where i think im going wrong
//ive tried window. and top. etc
var url = "http://www.google.co.uk/";
document.location.href = url
};
我对花式框的调用位于主页中。
任何帮助将不胜感激。
I'll try and keep this short. I have a page with various section. One section has an iframe with a google map in it. On the infowindows i have a link which when clicked i would like it to open in a fancybox over the page(not in the iframe...i can do that). For example if i had a link saying "google", id like it to open http://www.google.co.uk/ over the whole page in a fancybox.
I have 2 different pages and 2 javascripts, 1 for the map(iframe) and another for the main page. The function is in the main page script.
Where i think im going wrong is a) the right call to open the page b) attaching a class to the javascript i.e class="fancybox".
My map info window has this link in it(map.js):
<a href="javascript:parent.openSomething();">some content</a>
In my main.js:
function openSomething() {
//this is where i think im going wrong
//ive tried window. and top. etc
var url = "http://www.google.co.uk/";
document.location.href = url
};
My call to the fancy box is in the main page.
Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无需使用 JavaScript:将所需链接设置为
href
属性,并使用target
属性定义打开位置。target="_top"
将在整个页面中打开新链接target="_parent"
将在父框架或页面中打开它target="_blank"
将在新窗口中打开它。No need to use JavaScript: set the desired link as the
href
attribute, and use thetarget
attribute to define where it is opened.target="_top"
will open the new link in the entire pagetarget="_parent"
will open it in the parent frame or pagetarget="_blank"
will open it in a new window.