开发者

how to goto a page by code?

I tried using window.location="#pageLogin". It works in my desktop but appears a blank in my android device.

After doing some search,I uses $.mobile.changePage like this

var user;
$(document).ready(function(){
    user=GetCurrUser();
    if(user==null){
            $.mobile.changePage("#pageLogin", {
            transition: "pop",
            reverse: false,
            changeHash: false
        }); 
    }
});

Still nothing appears,e开发者_Go百科ven on desktop (Chrome).

Is there any better way to do that?

UPDATE The error message in firebug of $.mobile.changePage is settings.pageContainer is undefined


The jQuery Mobile way works for me, here's the example of code:

$.mobile.changePage($("#dashboard"), "none");

Not sure what could be your error. Can you try to reproduce it in jsFiddle?


window.location.href = "#pageLogin"; ?


location.replace(window.location.protocol + "//" + location.host + location.pathname + "#pageLogin")

Maybe that?


The problem is at $(document).ready(function(){});.It seems that the jQuery mobile framework had not loaded at this stage.I have to use $("#pageMain").live("pagecreate", function() {}); instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜