redirect to another page with slide effect

I have a functionality in jquery-mobile in which I want to redirect to another page on click of an image after a delay. So far i have reached till here-

setTimeout(function(){
    window.location.href = "myPage.html";
},1000);

Its working fine but I want that the page should redirect with slide effect of jQuery mobile. Doed anybody have any idea?

Answers


I got the answer guys..!!

I replaced window.location.href = "myPage.html" with

$.mobile.changePage("myPage.html",{transition:"slide"});

This is redirecting the page to the target page with slide effect! Check it out here


Redirecting a page with window location reload is not possible. When you try to change a window location reload it will refresh the page.

So you can try something like

  • loading your target content within an iframe

  • or, use ajax method to load content

  • or, make a sliding effect with your previously loaded content

In order to load via ajax use can use any one methods like .load() or .ajax()

For example:

You can use .load() like following:

$('#target_container').load('YOUR_URL', function() {
   // do something
});

OR can use .ajax() like following:

$.ajax({
  url: 'YOUR_URL'.
  dataType: 'html',
  success: function(response) {
    $('#target_container').html(response);
  }
});

Read more about above methods and use what you like.


Instead of setting window.location.href , Why dont you try this,

    $('#maindiv').load('mypage.html', function() {
       alert('Load was performed.');
      //  here slide the content and render the maindiv
    });

Redirecting a page like you did in your example code will make the page refresh and therefore an effect impossible. If you want to achieve something like a slidein page you might want to take a look at sliding in an iframe that holds the page that you want to redirect to (and maybe do the complete location refresh after the effect was finished).


Need Your Help

push automatically to other view controller

objective-c xcode cocoa ios5

How can i automatically push my view controller to another view controller? I got this code in viewWillApear, when my Tabledata contains 1 item it need to push it directly to another view controlle...

jQuery tabs: Post previously selected tab when opening a new one

jquery user-interface spring-mvc tabs form-submit

Having two forms, each in it's own jQuery UI tab, how can I post the form in the deselected tab when clicking a new tab?