简体   繁体   English

退出iframe html元素?

[英]quit iframe html element?

I am developing a html5 game app and I have two sections in my page, the menu and the game, which is in iframe. 我正在开发html5游戏应用程序,页面中有两个部分,分别是菜单和游戏(位于iframe中)。 when I open the app just the menu appears and if I click play' the menu is hidden (with jquery) and it writes in the Game section the iframe element: ( <iframe src="Game.html class="GameFrame" ></iframe> ) also in jquery. Now, the problem is that I cannot find a way to quit the iframe and show again the menu section. Has anybody an idea? Thank you, Boaz 当我打开应用程序时,仅显示菜单,如果单击“播放”,则菜单被隐藏(带有jquery),并且在“游戏”部分中写入iframe元素:( <iframe src="Game.html class="GameFrame" ></iframe> )也出现在jquery中。现在,问题是我找不到退出iframe并再次显示菜单部分的方法。有任何想法吗?谢谢Boaz

Basically you want to access parent window from inner iframe . 基本上,您想从内部iframe访问父window Use window.parent to access parent window. 使用window.parent访问父窗口。

If you have jQuery in parent window, you can access it by window.parent.$ from inner iframe and from there you know how to show/hide things. 如果父窗口中有jQuery,则可以从内部iframe中通过window.parent.$访问它,从那里您知道如何显示/隐藏东西。

For example: 例如:

(in iframe) (在iframe中)

window.parent.$('#menu').hide();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM