5

I am using Jquery1.8.2 and Jquery-mobile 1.1

When i click on Logout button i have to goto the Home page. I am able get the home page but before going back to the home page got the "Error Loading Page" message.

Test.html

<body>  
  <div data-role="page">
      <div data-role="header" data-theme="b" >
          <h1> Success Page </h1>
           <a data-role="button" id="logoutbtn" data-theme="b">Logout</a>
       </div><!-- /header -->
       <div data-role='content'>            
    </div>
</div>
</body>

test.js

$(document).ready(function(){   
$("#logoutbtn").click(function () {     
    document.location.href = "Home.html";
});
});

Please help me out on this.

4 Answers 4

7

You should be using the jquery mobile specific methods.

$.mobile.changePage("Home.html");

See document-location-href-location-vs-mobile-changepagelocation

Sign up to request clarification or add additional context in comments.

Comments

2

Thanks Dipaks

Instead of

document.location.href = "/Home.html";

I have modified it as like below

document.location.href = "./Home.html";

Its working fine and able to go back to home page with out any error.

Comments

1

$.mobile.changePage("Home.html") did not work on my PC

but instead $.mobile.changePage("#"); works and it's hiding the error loading page message.

Comments

1

I was using the right versions and $.mobile.changePage to change a page and it still failed with the same error. Later I realized that I was doing this in a js file in www/js/custom/handler/handler.js. So I was using paths relative to this location.

However later I realized that the path has to be relative to index.html that includes this js.

That resolved my issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.