Hello Monks,

I'm trying to incorporate a simple "open window" Javascript into my Perl script. I'm having a little trouble.

The first problem involves the Close Window routine. When I click the button to close the window; every window closes not just that one. This is what happens when I test outside the Perl/CGI script.

Here's the Javascript code for Close Window.
<INPUT type="button" value="Close Window" onCLick="window.close();">


When I incorporate all of the Javascript into my Perl/CGI script, the phrase "Shipping and Tax" does not appear as a hyperlink. The way this open window should behave is when a person clicks the "Shipping and Tax" link, the new window should open, the person then can close that window, and be returned to the previous window. Instead, I'm totally getting kicked out and I can't create the "Shipping and Tax" link.

Here's the first bit of Javascript code that defines the function for open window.
# Javascript to create popup window my $JSCRIPT; $JSCRIPT=<<EOF; function launchwin() { window.open("../shiptax.htm", "dialog", "width=300, height=250, scroll +bars=yes, resizable=yes"); } EOF ;

This piece of code calls the Javascript.
print header (-cookie => $cookie), start_html (-title => "Test Site", -script=>$JSCRIPT, -backgro +und=>"../images/sb0068.jpg", -leftmargin=>"0", -topmargin=>"0"), add_boilerplate ($page), end_html ();

Finally, this piece of code should have the phrase "Shipping and Tax" as a hyperlink, when clicked, should open the window.
$page .= p({ -style => "font-family: verdana; font-size: 10pt;" }, "Sh +ipping and tax may be added to your order.\n" . "To estimate shipping and tax, please see the " . a({-onClick => "launchwin"}, "Shipping and Tax") . " page.\n");

I hope someone can give me some help.
Thanks.

In reply to Perl/CGI/Javascript Problem by b310

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.