By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,708 Members | 2,080 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,708 IT Pros & Developers. It's quick & easy.

How do I get/read the url from the address filed in web browser

P: 4
My perl file is today shown/running "inside" a web page. My task is to redirect the user to a different web page depending on which web page thta is "holding" my perl file. Unfortunately I can't work out how to obtain the url string from the web page. I have successed with the same thing using javascript which is something like:

var url = parent.window.location;
how do I do this in perl?
Please help!

Aug 22 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 126
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. print "Content-type: text/html\n\n";
  3. my $url = $ENV{SERVER_NAME} . $ENV{REQUEST_URI};
  4. print "<html><body><h2>The URL was $url</h2>";
  5. print "<h3>The other hash variables available are:</h3><p>";
  6. foreach (sort keys %ENV) {
  7.         print "$_ = $ENV{$_}<br />";
  8. }
  9. print "</p></body></html>\n";
Oct 1 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.