Saturday, December 31, 2011

Redirecting to different links on a page using Javascript


In web applications its very simple to redirect to a particular page than the $$return field.
Sometimes there may be a need to redirect to a different forms depends on the actions done on the current form.

So, we can use the links to redirect to different forms.

Give the <a> tag as the first link which you want to redirect as shown below.

<a href="URL">Click here</a>


Give this as pass through html. And you can call this link in javascript functions to redirect when the action completed. You can call this link as follows.

function samplefunction()
{
...
...
document.links[0].onclick()
//Instead "zero" you can also use loop with  variable like "i", if there are more <a> tags
}


When the function is completed, it will automatically redirect to that URL.
I think this hint will reduce most of your time.

No comments:

Post a Comment