Pass text to popup window

T

Treetop

I would like to pass text to a popup window to save creating a new
html file for each help topic.
I would like to have a value for the heading, a value for the text,
code for printing the help page, and code to close the window.

------------------------------------------
the help window code is following

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}
// End -->
</script>

</head>
<body>
<h1 align="center">How to View Results</h1>

<ol>
<li>Locate the Application
<li>Leave your mouse over the application and the
popup window displayed
<li>Press the Page Down button on your keyboard
</ol>

<br><br>
<table width="100%"><tr><td>
<a href="javascript:printWindow()">
Print This Help Page</a>
</td><td align="right">
<a href="javascript:eek:nclick=window.close()">
Close This Help Page</a>
</td></tr></table>


------------------------------------------------
Currently I use the following code for a popup.

<script language="JavaScript">
function popup(theURL){
window.open(theURL,"pop","height=300,width=300")
}
</script>


<a href="bfmenu.html" value="tip_print.html"
onClick="popup(this.value)">Print</a>...

<a href="bfmenu.html" value="tip_view.html"
onClick="popup(this.value)">View entire results</a>...
 
K

kaeli

I would like to pass text to a popup window to save creating a new
html file for each help topic.
I would like to have a value for the heading, a value for the text,
code for printing the help page, and code to close the window.

Want mine?

It uses a javascript array for help menu values and the call tells which
menu to open.
The window is reused if open. The window document is written dynamically
with the text value in the array.

You can add simple code to close it (or print it) with a link. My users
know how to click on the 'x'. :)

--
 
T

Treetop

I would love it. If you would prefer to E-Mail it to me (remove
nospam)
(e-mail address removed)
 
K

kaeli

I would love it. If you would prefer to E-Mail it to me (remove
nospam)
(e-mail address removed)

It's not all that big (well, I took out all but two of my help screens
for the sake of example; the real file is quite long with a help screen
for every form field). Watch for word wrap.
Note: tested in IE5+/NN4+/Moz1.2 only. Some functions may not work in
other browsers. This is used for an intranet app where I know my users,
so if you don't, add error checking and fallback. However, I'm not doing
anything fancy, and I use the evil javascript: in a link so it works in
NN4 (no onClick of image in NN4).

File 1: jsHelp.js: put help descriptions in here like you see with the
basic "help" and "h_qty". Note that all my "Screens" except "help" begin
with "h_" to keep var names unique, as many js files are included in the
site.

-----------------------
/*jsHelp.js
Has help functions

var h_window = null;
var h_array = new Array();
/* descriptions that remain constant */
h_array["help"] = "<p>Click on any of the help icons to bring up a
javascript window "+
"with relevant information.</p>";
h_array["h_qty"] = "<h1>Quantity</h1>" +
"<p>Description: the number of this item in this
order. Left blank, the quantity will be 1.</p> ";

// put more below this

/* functions that get called when user presses a help button */
function openHelp(screenName)
{
if (!h_window || h_window == null || typeof h_window == "undefined" ||
h_window.closed || !h_window.document)
h_window = window.open("","Help","height=200,width=
200,scrollbars=yes,resizable=yes");
var doc = h_window.document;
doc.open();
doc.writeln("<html><head><title>Help</title>");
doc.writeln("<link rel='stylesheet' type='text/css'
href='myStylesheet.css'>");
doc.writeln("</head><body>");
doc.writeln(h_array[screenName]);
// add close and / or print links/buttons here
doc.writeln("</body></html>");
doc.close();
h_window.focus();
return;
}

/* end jsHelp.js */

----------------------------

in the html file, in the head
<script language="javascript" type="text/javascript"
src="jsHelpFunctions.js"></script>

in the body...
I use a help icon for the users to click on. Modify as appropriate.
<a href="javascript:eek:penHelp('help)"><img src="help.gif" width="15"
height="15" border="0"></a>
If using new browsers only, change to onClick of image, which is better.
Old NN doesn't support that and not sure on Opera support.

To make a close button or link, use self.close().
To mail, use self.print() (I think).
You would add that to what gets printed in the window by adding it in
the help file where I put that comment in.

HTH

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,078
Messages
2,570,570
Members
47,204
Latest member
MalorieSte

Latest Threads

Top