2011-03-03 123 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'); 

这一个为我工作。