Results 1 to 25 of 25

Thread: Go Back... *RESOLVED*

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Go Back...

    No javascript?

  3. #3

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Go Back...

    javascript:history.go(-1);

  5. #5

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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....

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Go Back...

    Try...

    call window.history.back(1)

    or

    call window.history.back(-1)


    Just play around with that, will ya?

  8. #8

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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.

  9. #9

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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.

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Go Back...

    Quote 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.

  11. #11
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Go Back...

    Show your code, how are you trying to implement the back navigation thingimijig?

  12. #12
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  13. #13

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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.

  14. #14
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Go Back...

    Quote 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?

  15. #15

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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.

  16. #16
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Go Back...

    When are you calling GoBack()?

  17. #17

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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.

  18. #18
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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:
    1. lnkGoBack.Attributes.Add("onClick","javascript:history.go(-1);")

    That should be the correct syntax. I don't have the IDE open right now.

  19. #19

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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.

  20. #20

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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.

  21. #21
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    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!

  22. #22
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Go Back...

    Quote 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.

  23. #23

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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.

  24. #24
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Go Back... *RESOLVED*

    Hmm.. point there.

    Confused me there, but it works, so it works!

  25. #25

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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
  •  



Click Here to Expand Forum to Full Width