Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect to another page

Status
Not open for further replies.

BPMan

Programmer
Jun 25, 2002
163
0
0
US
I want to run a javascript that checks some criterion and then either just leaves the page be or goes to a different url..
so something like
<script>
if(criterion)
redirectTo(</script>

how do i do this?
what function would i use?
thanks
 
Hi BPMan

Here is some code you could use :

<html>
<head>
<script>

function criteria()
{
if(criterion)
{
windowopen();
else
{
windowopentwo()
}
}
}

function windowopen()
{
window.open(&quot;}

function windowopentwo()
{
window.open(&quot;anotherwebsite.com&quot;)
}

</script>
<head>
<body onload = criteria()>

</body>
</html>
 
i do not want it to open another window....
i want it to go to a different url but in the same window....
thanks
 
here's some syntax for you to work with
function goSomewhere() {
if (something == &quot;&quot;) {
location.href=&quot;another.htm&quot;;
}

I dare to learn more
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top