Re: [問題] 關於frame的問題

看板Web_Design作者 (道可道非常道)時間14年前 (2010/03/25 01:17), 編輯推噓1(103)
留言4則, 3人參與, 最新討論串3/3 (看更多)
假設 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
取路徑,比如 http://xxx/redirect.js -> http://xxx/
03/25 14:43, 4F
文章代碼(AID): #1BgaaL-8 (Web_Design)
文章代碼(AID): #1BgaaL-8 (Web_Design)