Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Perl html help message

How do I create a new html form

9:43 pm on Dec 11, 2008 (gmt 0)

5+ Year Member

I would like to have a help/about information html form spawn from my perl program (without the need for a second cgi or perl file. I would prefer to have a new form open up without disturbing the parent browser window. Like a dialog box on steroids.

I have investigated javascript dialog boxes but they are limited in size and lack html formatting or line control i.e breaks. (Yes, I have tried "\n" but this no longer works with current javascript compilers)

Any suggestions? - Thanks for the help

I have created a cgi directory listing program and don't want to make the user have to browse away from the listing.
I have a small "about" javascript button at the bottom. I would prefer to supply a table of contents and substantial other setup information.

[edited by: phranque at 1:22 pm (utc) on Dec. 12, 2008]
[edit reason] No urls, please. See TOS [webmasterworld.com] [/edit]

2:22 pm on Dec 12, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Not sure what you're getting at, but a few comments:

Yes, I have tried "\n" but this no longer works with current javascript compilers

\n works fine:

<a href="myhtml.html" onClick="return some_alert();">click</a>

<script type="text/javascript">
function some_alert() {
var msg = 'This is some message\n'+
'in JS with newlines. But if you\n'+
'generate it from perl you have to\n'+
'DOUBLE escape the newline.';
return false;

The reason being, perl (or PHP) will escape the \, leaving you with an "n" at the end of each line.

However, it sounds to me like you want a form or other supplemental content, so the alert box will not work.

Just use JS new window methods with a blank target in case JS is disabled. Where "myform.html" is your form, help file, script, or other supplemental content,

<a href="myhtml.html" onClick="return newWin('myform.html','400','400');" target="new window">HELP!</a>

<script type="text/javascript">
function newWin(url,w,h) {
// Insures you ALWAYS get a NEW window by
// setting a unique ID for window name:
var day = new Date();
var id = day.getTime();
var ww = w+75; // add some padding for window
var wh = w+125;
// ALWAYS heep it resizable with scrollbars
var params = 'width='+ww+',height='+wh+',scrollbars,resizable';
var win=open(url,id,params);
return false;

As mentioned, if you generate JS from your perl script, double escape any newlines you want to appear in the Javascript, like \\n.

9:04 pm on Dec 13, 2008 (gmt 0)

5+ Year Member

Thanks for all the help! This is what I came up with that does what I need... Thanks again - JZ

function newWindow() {
info.document.write("<html><head></head><body>hello world</body></html>")

3:57 pm on Dec 14, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

I'm *really surprised* that works at all. :-) When you do a document.write(); you need to flush the buffer with document.close(). Otherwise you get a blank page (or at least used to . . . )

While you're at it, you don't need to specify yes/no for your window parameters; including them means yes, excluding them means no.

LANGUAGE is no longer required, just describe the mime type.

Last, see the previous example for the window name/id, in your scenario all subsequent clicks on the link will open in the same window named "Information." This is not a title, it's an ID for the window. Using the method described will always insure it opens in a new window.

<script type="text/javascript">
function newWindow() {
var day = new Date();
var id = day.getTime();
info.document.write("<html><head></head><body>hello world</body></html>");

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month