Simple Machines Community Forum

General Community => Scripting Help => Topic started by: Tomer on July 02, 2005, 04:03:16 AM

Title: Redirecting
Post by: Tomer on July 02, 2005, 04:03:16 AM
I need to redirect a page after a prompt [like in SMF when you recieve a message], how can this be done?

- Thanks
Title: Re: Redirecting
Post by: [Unknown] on July 02, 2005, 04:11:27 AM
Just change window.location.href.

-[Unknown]
Title: Re: Redirecting
Post by: Tomer on July 02, 2005, 04:22:03 AM
I'm using this:


function message()
{
      var Your_Name = confirm("You have recieved a message, do you wish to view it?")

   if (Yes_or_No == 1) { // user clicked ok.
window.location.href = '/?page=test'
   }
}

</head>
<body onload="message();">


Whats wrong with it?

- Thanks
Title: Re: Redirecting
Post by: [Unknown] on July 02, 2005, 04:23:51 AM
You're using different variables.  I would just use:

if (confirm("You have recieved a message, do you wish to view it?"))
   window.location.href = '/?page=test';

-[Unknown]
Title: Re: Redirecting
Post by: Tomer on July 02, 2005, 05:24:13 AM
Thanks