CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Perl script to open new window


New User

Mar 23, 2013, 10:21 AM

Post #1 of 3 (1099 views)
Perl script to open new window Can't Post

I am working on a YaBB 2.5.2 mod which is executable from any page of the forum because it is form driven and the form is within the HTML template code.

The mod simply runs a sub-routine (subroutine #1) to roll a/some polyhedron die/dice and log the results. A hyperlink at the bottom of the HTML form used to pass variable data to the perl code bypasses the variables and redirects to the logged results (subroutine #2). If subroutine #1 is run passing variables and determining results, it then appends the results to an array of strings and calls subroutine #2 to display all of the logged results.

Now I have a little delimma. I have the following code at the end of subroutine #1:

  $yySetLocation = qq~$scripturl?action=logrolldisplay~;  

After the form is executed, it redirects you to a log of results (subroutine #2). That works great, mind you... except I'm concerned that someone might be in the middle of doing something else and then get whisked away to the log results inadvertently. What I would like is to append the code in such a way that it uses the above code if you are already looking at the log of results ($scripturl?action=logrolldisplay), but if you are not, it opens up a separate window.

Any idea how can I do this?


Mar 23, 2013, 8:42 PM

Post #2 of 3 (1087 views)
Re: [ImpInTraining] Perl script to open new window [In reply to] Can't Post


Not entirely certain what you are trying to achieve, I don't fully understand your requirements.

Maybe the following will help:

- $ENV{'SCRIPT_URI'} might be available to you and will contain the URL you have landed on (non standard mod rewrite environment variable). Dump %ENV and see what you have available to use.
- You can open a new window using javascript.

my $log_url = qq{$scripturl?action=logrolldisplay}; 

if ( $ENV{'SCRIPT_URI'} eq $log_url )
# already looking at log therefore redirect.

# perform redirect...
# not looking at log therefore open new window.

print qq{content-type: text/html\n\n};
print qq{<script type="text/javascript">'$log_url')</script>\n};

( Be careful of endless redirect / new window loops ).


(This post was edited by Zhris on Mar 23, 2013, 8:52 PM)

New User

Mar 23, 2013, 9:28 PM

Post #3 of 3 (1075 views)
Re: [Zhris] Perl script to open new window [In reply to] Can't Post

Thanks ... will give it a try.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives