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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Emmalo
    New Member
    • Aug 2008
    • 4

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

    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.l ocation;
    how do I do this in perl?
    Please help!

    /Emmalo
  • Stwange
    Recognized Expert New Member
    • Aug 2007
    • 126

    #2
    Code:
    #!/usr/bin/perl
    print "Content-type: text/html\n\n";
    my $url = $ENV{SERVER_NAME} . $ENV{REQUEST_URI};
    print "<html><body><h2>The URL was $url</h2>";
    print "<h3>The other hash variables available are:</h3><p>";
    foreach (sort keys %ENV) {
            print "$_ = $ENV{$_}<br />";
    }
    print "</p></body></html>\n";

    Comment

    Working...