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
FYI
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]
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.';
alert(msg);
return false;
}
</script>
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;
}
</script>
As mentioned, if you generate JS from your perl script, double escape any newlines you want to appear in the Javascript, like \\n.
<SCRIPT LANGUAGE="JavaScript">
function newWindow() {
info=window.open("","Information","toolbar=yes,scrollbars=yes,width=300,height=300");
info.document.write("<html><head></head><body>hello world</body></html>")
}
</SCRIPT>
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=window.open("",id,"toolbar,scrollbars,width=300,height=300");
info.document.write("<html><head></head><body>hello world</body></html>");
info.document.close();
}
</script>