|
-
Apr 14th, 2005, 07:53 AM
#1
Thread Starter
Fanatic Member
Go Back... *RESOLVED*
In vbscript, how do you tell the browser to go back to the previous page?
Last edited by simonm; Apr 15th, 2005 at 04:48 AM.
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Apr 14th, 2005, 08:03 AM
#2
-
Apr 14th, 2005, 08:04 AM
#3
Thread Starter
Fanatic Member
Re: Go Back...
If you know the answer in Javascript, that'll do...
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Apr 14th, 2005, 08:22 AM
#4
Re: Go Back...
javascript:history.go(-1);
-
Apr 14th, 2005, 08:40 AM
#5
Thread Starter
Fanatic Member
Re: Go Back...
Actually, that's no good for me. I am doing this project in VB.NET and with VB Script.
There doesn't seem to be a history object available to use...
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Apr 14th, 2005, 08:47 AM
#6
Re: Go Back...
Are you absolutely restricted to VBScript? That seems to be an odd choice because VBSCript would imply an IE-only environment, and IE supports javascript for that matter....
-
Apr 14th, 2005, 08:49 AM
#7
Re: Go Back...
Try...
call window.history.back(1)
or
call window.history.back(-1)
Just play around with that, will ya?
-
Apr 14th, 2005, 08:50 AM
#8
Thread Starter
Fanatic Member
Re: Go Back...
I'm only restricted in as far as I know vb and I don't know java.
As for browser support, the script is being run at the server anyway so it shouldn't affect what browser the client uses, should it?
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Apr 14th, 2005, 08:51 AM
#9
Thread Starter
Fanatic Member
Re: Go Back...
There is no Window object either...
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Apr 14th, 2005, 08:59 AM
#10
Re: Go Back...
 Originally Posted by simonm
I'm only restricted in as far as I know vb and I don't know java.
As for browser support, the script is being run at the server anyway so it shouldn't affect what browser the client uses, should it?
No, client side scripting (namely javascript and vbscript) run on the end-user's machine. Even when a postback occurs on your aspx pages, it's done using javascript. (Ever took a look at the source of the output?)
It therefore becomes browser dependent, and if you use vbscript entirely for your client side scripting, then you are restricting your viewers to ONLY IE. And an FF user like me would just not visit.
-
Apr 14th, 2005, 09:00 AM
#11
Re: Go Back...
Show your code, how are you trying to implement the back navigation thingimijig?
-
Apr 14th, 2005, 09:01 AM
#12
Re: Go Back...
And take a look at this too:
http://support.microsoft.com/?kbid=205693
There should be a window object. I haven't tried this myself because the IE icon is not visible to me right now.
-
Apr 14th, 2005, 09:07 AM
#13
Thread Starter
Fanatic Member
Re: Go Back...
This site is not for the general public, only for business to business communcations.
And my script is all server side anyway.
And I have no code to go back...I have nothing...
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Apr 14th, 2005, 09:09 AM
#14
Re: Go Back...
 Originally Posted by simonm
And my script is all server side anyway.
I don't believe you. Actually, I think there's a slight misunderstanding. SHOW me what you have. You cannot have VBSCript Server side for asp.net.
And I have no code to go back...I have nothing...
What?
-
Apr 14th, 2005, 09:14 AM
#15
Thread Starter
Fanatic Member
Re: Go Back...
All right, here's what I have:
Code:
<script runat="server">
Sub GoBack(sender As Object, e As System.EventArgs)
Window.History.GoBack(-1)
End Sub
</script>
When my page loads, I get the following error: "Name 'Window' is not declared."
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Apr 14th, 2005, 09:28 AM
#16
Re: Go Back...
When are you calling GoBack()?
-
Apr 14th, 2005, 09:54 AM
#17
Thread Starter
Fanatic Member
Re: Go Back...
From here:
Code:
<asp:LinkButton id="lnkGoBack" OnClick="GoBack" runat="server">Back</asp:LinkButton>
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Apr 14th, 2005, 07:49 PM
#18
Re: Go Back...
You're making things complex for yourself. A simple:
Code:
<a href='#' onClick="javascript:history.go(-1);">Back</a>
would do for you!
But if you still want to use the <asp:LinkButton>, then...
Change this:
Code:
<asp:LinkButton id="lnkGoBack" OnClick="GoBack" runat="server">Back</asp:LinkButton>
to
this:
Code:
<asp:LinkButton id="lnkGoBack" runat="server">Back</asp:LinkButton>
In the page load event,
VB Code:
lnkGoBack.Attributes.Add("onClick","javascript:history.go(-1);")
That should be the correct syntax. I don't have the IDE open right now.
-
Apr 15th, 2005, 03:06 AM
#19
Thread Starter
Fanatic Member
Re: Go Back...
Thanks...but it's really causing problems for me using Javascript...
It must be possible in vbScript (or in VB.NET code), surely?
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Apr 15th, 2005, 04:48 AM
#20
Thread Starter
Fanatic Member
Re: Go Back...
Actually, modifying your first example to vbScript wasn't difficult:
Code:
<a href='#' onClick="history.go(-1)">Back</a>
I guess the problem I was having was that the history object isn't available on the server. It had to be run on the client side...
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Apr 15th, 2005, 05:06 AM
#21
Frenzied Member
Re: Go Back... *RESOLVED*
In theory you could do it server-side like so:
Code:
<script runat="server">
Sub GoBack(sender As Object, e As System.EventArgs)
Response.Redirect(Request.UrlReferrer.ToString())
End Sub
</script>
It is redirecting you to the referring page (previous page). However I haven't tried it and I'm not sure what it'll do if the page has already done a postback (redirect back to itself?!?). Give it a try - you never know!
mendhak is right though if you are using ASP.NET you are using client-side JavaScript already just view the source of an ASP.NET generated page - it's all over the place! I do however try to develop pages so they still work with JavaScript disabled for accessibility reasons - it ain't easy let me tell you!
DJ
If I have been helpful please rate my post. If I haven't tell me!
-
Apr 15th, 2005, 05:52 AM
#22
Re: Go Back...
 Originally Posted by simonm
Actually, modifying your first example to vbScript wasn't difficult:
Code:
<a href='#' onClick="history.go(-1)">Back</a>
I guess the problem I was having was that the history object isn't available on the server. It had to be run on the client side...
I was trying to explain that to you...
Oh, and I hate to burst your bubble but that's javascript, I'm pretty sure.
-
Apr 15th, 2005, 06:04 AM
#23
Thread Starter
Fanatic Member
Re: Go Back... *RESOLVED*
Mendhak
My aspx page has the following property set:
Document.defaultClientScript = VBScript
so I would be suprised if it was javascript...
Indeed, if I change the code like this, it must surely be interpreted as vbScript, no?
Code:
<a language =vbscript href='#' onClick="history.go(-1)">Back</a>
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Apr 15th, 2005, 06:24 AM
#24
Re: Go Back... *RESOLVED*
Hmm.. point there.
Confused me there, but it works, so it works!
-
Apr 15th, 2005, 10:23 AM
#25
Thread Starter
Fanatic Member
Re: Go Back... *RESOLVED*
Yep, thanks.
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|