作者danny0838 (道可道非常道)
看板Web_Design
標題Re: [問題] 關於frame的問題
時間Thu Mar 25 01:17:06 2010
假設 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)
→ davidou:感謝你 我會實驗看看的 03/25 10:35
→ davidou:/[\\\/][^\\\/]*$/,'/') 這串是甚麼意思@@ 看不懂 囧 03/25 10:55
推 shiiz:尋找字串? 03/25 11:54