How can I redirect automatically to an other page of my WebApp

520 Views Asked by At

I am currently developing a Web App under jQTouch, and I want to know how I should proceed to redirect the user automatically to another page of my Web App.

For instance, let's suppose I have this code :

 <div id="foo1">
      ...
 </div>
 <div id="foo2">
      ...
 </div>

Now, let's suppose that the currently visible block is foo1. Which code should I write in my JavaScript file to redirect to block foo2 (as though I clicked a link with href="#foo2")?

Thanks and sorry for my English (I'm French).

2

There are 2 best solutions below

1
On

A standard link

<a href="#foo2">Link</a>

will not work, but you are on the right track, it just has to be in the correct setting (either a button, or a list). so either:

<ul class="rounded">
   <li class="arrow">
       <a href="#foo2">Link</a>
   </li>
</ul>

or

<a class="button" href="#foo2">Link</a>

will work.

0
On

You may use the jQT.goTo() to transfer to another page, e.g.

jQT.goTo('#foo2', 'slideup');

If you just want to trigger a click event on a link, you could use the click function in jQuery:

<a id="goToFoo2" href="#foo2">Go To Foo2</a>
<script>$("#goToFoo2").click()</script>