Using Location object with VBScript

I am trying to use the Location object to go from one ASP page to another and get a VBScript runtime error: Variable is undefined: Location.

Here's the code I'm using;

<% Location.Href="test.asp" %>

Is it possible to use the Location object with VBScript?  Every example I've seen is using JavaScript.  If you can't use it from VBScript, then how do you jump to another page?  I can't use the Response.Redirect because I've already displayed HTML to the browser.  The Response.Redirect has to execute before any HTML code.
tonylclaytonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

clockwatcherCommented:
Location is a client-side object of the browser.  It has nothing to do with server-side code.

There's very little point in using vbscript as only IE understands it-- but if you really want to, you simply have to move it client-side.

<script language=vbscript>
location.href = "http://www.yahoo.com"
</script>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
clockwatcherCommented:
If you really want to use response.redirect after writing content, you can buffer your response.

<%
response.buffer = true
%>
<html>
<body>
Whatever
</body>
</html>
<%
response.redirect "http://www.yahoo.com"
%>
0
MarineCommented:

right after this line put that line below <%<@language="vbscript"%>
response.buffer = true ]

then you can use response.redirect ("url.asp")
anywhere in your code
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

tonylclaytonAuthor Commented:
Thanks!  But if you don't use the location.href to move to another page, how do you do it?
0
MarineCommented:
the response.redirect will take you to another page. Desn't it ?
you must set response.buffer = true if you want to use it before outputing any html.
0
clockwatcherCommented:
I'm not sure what you're asking?  Do you want to move to another page after you've displayed some content or do you actually want to do redirect.

Server-side, the only way to move to another page is with a redirect.  Basically, you're telling the client that the page they've requested is no longer there and that it's really somewhere else.  That's why you have to buffer the content or send it out before sending any html-- it's a header value.

Client-side there are a couple of ways to redirect.

You can use a meta tag:

  <meta http-equiv="refresh" content="5;URL=http://www.yahoo.com">

You can use inline javascript

<html>
<body>
It is now: <%=now%>
<script language="javascript">
  location.href="http://www.yahoo.com"
</script>
</body>
</html>

You can use a function:
<html>
<head>
<script language="javascript">
function move() {
  location.href = "http://www.yahoo.com";
}
</script>
</head>
<body onload="setTimeout('move()', 5000">
Whatever
</body>
</html>
0
tonylclaytonAuthor Commented:
I actually want to move to another page after I've displayed some content.  I did not know about the Response.Buffer statement.  I tried that and it worked.

Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.