2011-03-03 58 views
1

是否有可能「重定向」用戶從一個子頁面,即。 index.htm#子頁面index.htm#home與mobileinit函數?重定向到首頁

$(document).bind("mobileinit", function(){ 
    $.mobile.changePage("/index.htm#home"); 
}); 

回答

3

爲什麼不

$(document).bind("mobileinit", function(){ 
    document.location.href="whereever"; 
}); 

或只是

<script> 
document.location.href="whereever"; 
</script> 

,甚至有元標記?

+0

嗨, 謝謝,我爲你的第一個例子,工作greate :) – 2011-03-04 09:05:18

+1

HTTP302服務器端重定向會好得多 - 目前整個頁面加載和100KB的jquery的東西加載。想想看 – naugtur 2011-03-04 12:49:49

1

是的。如果您使用重定向,非Ajax網頁必須重新加載超過100KB的JQuery JS .... 我仍然不想,但在某些情況下,它必須通過頁面重新加載來完成(仔細處理PHP會話)。

3
$.mobile.changePage('#page_two'); 

這一個爲我工作。