iT邦幫忙

0

請教關於DIV內的iframe內的頁面該如何關閉視窗

kushu 2014-08-22 11:43:1412341 瀏覽
  • 分享至 

  • twitterImage

<div id="ware032">
<iframe src="Welcome.html" name="EDIT" width="100%" marginwidth="0" height="800" marginheight="0" align="top" scrolling="no" frameborder="0"></iframe></div>
</div>

我上GOOGLE查到
parent.window.close();
top.window.close();
添加在iframe內的頁面.都無法將遊覽器整個關掉
但是單獨頁面測試又可以關閉

應該是你的javascript有錯誤開chrome 按ctrl+ shift+i 看Console 頁籤,你開著執行網頁就可以看到是否有無錯誤,不然就檢查一下你的html標籤是不是有問題。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
bluesky1213
iT邦新手 3 級 ‧ 2014-08-22 11:57:42
最佳解答

kushu提到:
parent.window.close();

test.html

&lt;pre class="c" name="code">

	&lt;title>&lt;/title>


&lt;div id="ware032">
&lt;iframe src="Welcome.html" name="EDIT" width="100%" marginwidth="0" height="800" marginheight="0" align="top" scrolling="no" frameborder="0">&lt;/iframe>&lt;/div>
&lt;/div>

Welcome.html

&lt;pre class="c" name="code">

	&lt;title>&lt;/title>
	&lt;script type="text/javascript">
	function Close()
	{
	   parent.window.close();		
	}
	&lt;/script>


Welcome!
&lt;button id="close" onclick="Close()">Close&lt;/button>

測試過是可以正常關閉的
瀏覽器:Google Chrome 版本 36.0.1985.143 m

看更多先前的回應...收起先前的回應...
kushu iT邦新手 5 級 ‧ 2014-08-22 14:47:54 檢舉

不好意思
我可能沒把問題表達清楚
我現在遇到的狀況是我在
<div id="ware03">內分成<div id="ware031">左跟<div id="ware032">右
然後在ware032插入<iframe src="Welcome.html" name="EDIT">
之後我在ware031使用連結把ware032下的iframe src="Welcome.html"網頁換成了Requisition.php之後使用插入記錄完成跳轉到ok.php

最後頁框內顯示的是ok.php 要使用關閉的語法是用在ok.php

真的抱歉.新手發問.沒把問題說清楚
煩請大大再幫我解決一下.謝謝

如果只是跳轉那是一樣的道理啊~~你把該有的javascript套用在ok.php那頁就好了。

kushu iT邦新手 5 級 ‧ 2014-08-26 17:32:32 檢舉

我用CHROME
版本 36.0.1985.143 m
測試不行耶
網址
changli.no-ip.org/changli/test.php
能幫我看看問題出在哪嗎?
IE第一頁能關掉視窗煥業後也不行了

function 內在parent.window.close();之前加上window.opener = window;
另外 你function 命名是大寫Close 你套用的時候卻是小寫close

kushu iT邦新手 5 級 ‧ 2014-08-30 12:06:13 檢舉

bluesky1213提到:
window.opener = window;

IE能正常執行
但是CHROME 怎麼試都沒辦法關閉 只有單獨開啟檔案的時候能關閉
謝謝你的幫忙
時間快到了 先結案吧

我要發表回答

立即登入回答