Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Get full url

by srchulo (Sexton)
on Oct 30, 2011 at 11:01 UTC ( #934698=perlquestion: print w/replies, xml ) Need Help??
srchulo has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

Right now I am in a situation where I would like to be able to get the full URL of the script that is running. For instance,

http://beta.gearheadgaragesale.com/search.htm#red%20bmw

Would return everything, including the # onward. I need this because I am updating a page via AJAX, and I would like the user to be able to copy and paste the link and have someone else see the results they were viewing, and so I need the whole URL so that perl can pre fill the page. I am using the "#" instead of the "?" because when I append the "?" to the end of the URL with Javascript, it reloads the page.

I was not able to find an environment variable that does this. Is it even possible? Thanks!

Replies are listed 'Best First'.
Re: Get full url
by Corion (Pope) on Oct 30, 2011 at 11:06 UTC

    The URL fragment (the part behind #) is never sent to the server. You will need to change your javascript so it does not use the fragment. Find out how to make your Javascript not reload the page when it fetches another URL.

      Okay, thanks for letting me know! Now on to finding a JS solution :)
Re: Get full url
by moritz (Cardinal) on Oct 30, 2011 at 11:06 UTC
      Though javascripts can access it through DOM

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://934698]
Approved by moritz
help
Chatterbox?
[marto]: there are many, to this day.
[ovedpo15]: @Corion Yes I use the regex you showed me. its very good regex. although now i need to know that substring unit that comma
marto mad corrections to one around 18 months ago
[ovedpo15]: my code checks the value after that comma, if it isn't valid it will remove it. so I would like to remove the substring after that comma meaning getting the string before comma.
[hippo]: Are you sure that Text::CSV_XS isn't already installed at your work? It's such a useful module that it might well be there.
[marto]: pointing out the advantages of cpan modules is well worth in, as both developer and $client/$company benefit greatly
[Tux]: $src =~ m{^(.*),(.*)$/ and $2 !~ $valid and $src = $1;
[Tux]: s,/,},

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2018-05-27 10:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?