« Previous Next »

Thread: How to retrieve the current page's URL in vbScript?

Last post 06-12-2009 6:04 PM by x-format. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 06-11-2009, 11:42 AM

    • x-format
    • Not Ranked
    • Joined on 08-26-2008, 5:59 PM
    • Posts 2

    How to retrieve the current page's URL in vbScript?

    Hello!

    I'm trying to retrieve the current page's URL in vbScript but whatever I do doesn't work. I'm new to vbScript and I created a button for IE that will redirect me to a given url to which I'd like to append the current page's url.

    I've searched the web for quite some time and I've found some 'solutions' but none of them worked. If I used a msgbox to display the URL of the current viewed page it's always empty, no matter what...

     I've tried this:

    http://www.webcheatsheet.com/ASP/get_current_page_url.php

    and this

     

    a = "url"
    loc = window.location.href
    msgbox(a & ": " & loc)
      

     but loc variable is empty...

     

    I desperately need this because I have a web directory and I'd like to be able to add different websites to my directory by clicking the custom button instead of copying the url, navigate to my web directory and submitting the url...

     

    Please help!

     thank you in advance :)

     

    I've posted the same message on asp.net forums but no luck...(see http://forums.asp.net/t/1434209.aspx)

     

    PS

     

    If I use this code:

    set shlApp = createobject("shell.application")
    for each wdw in shlApp.windows

      Wscript.Echo wdw.locationUrl
    next

     

    I get all urls; is there a way to detect the current viewed (tab) page ?

  • 06-11-2009, 1:00 PM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Central NJ
    • Posts 6,189
    • IIS MVPs

    Re: How to retrieve the current page's URL in vbScript?

    Your'e using vbscript in client-side script?  This is a server-side classic ASP forum ...

    ... anyway, that webcheatsheet link shows you the correct way to get that URL in clasic ASP.  You can then mix that with your client-side script like this ...

    <script language = "vbscript">
    a = "url"
    loc = "<% response.write(curPageURL()) %>"
    msgbox(a & ": " & loc)
    </script>

  • 06-12-2009, 6:04 PM In reply to

    • x-format
    • Not Ranked
    • Joined on 08-26-2008, 5:59 PM
    • Posts 2

    Re: How to retrieve the current page's URL in vbScript?

    Thank you, but after endless tries I finally got it to work by using an html file and some javascript

Page 1 of 1 (3 items)
Microsoft Communities