Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

page redirection

Question posted by: Paul (Guest) on July 11th, 2008 09:15 AM
Hi all,

This will hopefully be a really simple question....

I'm a newbie at web app development, and am teaching my self as I go. I have
a page that requires a user to click a
button which then pops up a message box asking the user to make a choice.
Based on this choice, it will either redirect to another page or display a
message. I can get it to display a message, but when it tries to redirect I
get the error;

"Error: Object doesn't support this property or method: 'document.redirect'"

I have tried researching this error but cannot find a solution that works,
can anyone help?

The page code is as follows;

<form>
<INPUT TYPE="BUTTON" NAME="button_2" VALUE="Click Here!">

<SCRIPT LANGUAGE="VBScript" >
Sub button_2_onclick
answer=MsgBox ("Call Sheet", vbYesNoCancel, "Click Yes to create a call
sheet")
If answer = "6" then
document.write("answer = ")&answer
Else If answer = "7" Then
document.redirect="test2.html"
Else if answer = "2" then
exit sub
End If
End If
End If
End Sub
</SCRIPT>

</form>

Many thanks in advance

Paul

Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Paul's Avatar
Paul
Guest
n/a Posts
July 11th, 2008
10:15 AM
#2

Re: page redirection
Hi all,

sorry to waste your time, I have resolved it myself!!

Changed this line:-
document.redirect="test2.html"
To this:-
document.location.href="test2.html"

thanks again!

"Paul" <Paul@here.localwrote in message
news:D201461F-C97B-4573-B5C3-4FB86974D823@microsoft.com...
Quote:
Originally Posted by
Hi all,
>
This will hopefully be a really simple question....
>
I'm a newbie at web app development, and am teaching my self as I go. I
have a page that requires a user to click a
button which then pops up a message box asking the user to make a choice.
Based on this choice, it will either redirect to another page or display a
message. I can get it to display a message, but when it tries to redirect
I get the error;
>
"Error: Object doesn't support this property or method:
'document.redirect'"
>
I have tried researching this error but cannot find a solution that works,
can anyone help?
>
The page code is as follows;
>
<form>
<INPUT TYPE="BUTTON" NAME="button_2" VALUE="Click Here!">
>
<SCRIPT LANGUAGE="VBScript" >
Sub button_2_onclick
answer=MsgBox ("Call Sheet", vbYesNoCancel, "Click Yes to create a call
sheet")
If answer = "6" then
document.write("answer = ")&answer
Else If answer = "7" Then
document.redirect="test2.html"
Else if answer = "2" then
exit sub
End If
End If
End If
End Sub
</SCRIPT>
>
</form>
>
Many thanks in advance
>
Paul
>



Dave Anderson's Avatar
Dave Anderson
Guest
n/a Posts
July 11th, 2008
03:55 PM
#3

Re: page redirection
Paul wrote:
Quote:
Originally Posted by
Hi all,
>
sorry to waste your time, I have resolved it myself!!
>
Changed this line:-
document.redirect="test2.html"
To this:-
document.location.href="test2.html"


You should use window.location instead of document.location.
document.location is not part of any standard, while there is at least a
working draft that describes window.location:
http://www.w3.org/TR/Window/#location

See also:

"document.location was originally a read-only property, although Gecko
browsers allow you to assign to it as well. For cross-browser safety,
use window.location instead."

http://developer.mozilla.org/en/doc...cument.location

In any case, you can see for yourself that .redirect is not a method of
*any* DOM object:
http://msdn.microsoft.com/en-us/lib...053(VS.85).aspx




--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.



 
Not the answer you were looking for? Post your question . . .
182,494 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors