Re: [問題] 關於frame的問題
假設 index.html 裡面包著名為 main 的 frame,
###.html 被載入時導向至父框架頁 index.html,
並且把 main 連到 ###.html
先寫二個 js 檔:
<fix.js>
setTimeout(function(){var s=location.search;
if(s){document.getElementById('main').src=s.substr(1);};},0);
<redirect.js>
if(window==top){location.href='index.html'+'?'+location.href;}
index.html 引用 fix.js
其他 ###.html 都引用 redirect.js
如果 ###.html 可能在和 index.html 不同的資料夾下,可改成:
<redirect.js>
if (window==top) {
var e=document.getElementsByTagName('SCRIPT');
location.href=e[e.length-1].src.replace(/[\\\/][^\\\/]*$/,'/')+'index.html'+
'?'+location.href;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.160.49.79
※ 編輯: danny0838 來自: 118.160.49.79 (03/25 01:50)
→
03/25 10:35, , 1F
03/25 10:35, 1F
→
03/25 10:55, , 2F
03/25 10:55, 2F
推
03/25 11:54, , 3F
03/25 11:54, 3F
→
03/25 14:43, , 4F
03/25 14:43, 4F
討論串 (同標題文章)