2013-03-22 34 views
-2

未觀察時我有一個wc.html和我與代碼中的index.html:重定向在幀

<!doctype html> 
<html> 
    <head> 
     <meta charset="utf-8"> 
     <title>My title</title> 
    </head> 
    <frameset rows="*"> 
     <frame src="wc.html"> 
    </frameset> 
    <noframes></noframes> 
    <body> 
    </body> 
</html> 

,我想的是,當wc.html在索引分別與未觀看,它會重定向到索引頁面。

我該怎麼做?提前致謝。

+2

幀已從[HTML5]刪除(http://www.w3.org/TR/html5-diff/ #過時的元素)。 – hjpotter92 2013-03-22 07:46:34

+0

你爲什麼要使用幀?請參閱http://www.hobo-web.co.uk/website-frames/ – 2013-03-22 08:21:06

回答

0

試試這個,

if(window.parent.location.href==undefined){ 
    window.location="index.html"; 
} 
+0

框架已從[HTML5](http://www.w3.org/TR/html5-diff/#obsolete-elements)中刪除。 – hjpotter92 2013-03-22 07:47:16

0

你可以試試這個:

var location = window.location.href; 
    if(location.indexOf('wc') != -1 || location == undefined){ 
     window.location.href = "index.html"; 
    }