[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Perl variable within Javascript?
Hi, folks--
This is the last piece of a Perl puzzle, for me. I have a Perl
variable $sessionid that holds the value of a user sessionid. I
obtained the value by using my Perl script to connect to our catalog
through its Web interface. Now, I want to use that variable within
some Javascript on a new Web page that the Perl script generates, to
bring up a separate window for users to check their patron
information. With a little sleight of hand, I want to do something
like this:
<HTML>
<HEAD><TITLE>Patron info link</TITLE>
<SCRIPT LANGUAGE=Javascript>
var iwin;
function instruct()
{
iwin =
window.open("http://www.bobcat.nyu.edu/html/PatronCheck.html%3a%
3A$session_id", "iwin",
"width=550,height=450,scrollbars,resizable,status");
}
</script>
<META HTTP-EQUIV="Refresh"
CONTENT="0;URL=http://www.nyu.edu/library/bobst/database.htm">
</HEAD>
<BODY onLoad="instruct()">
<BR>
</BODY></HTML>
Everything works fine, with the Patron info window coming up in front
of a blank window that quickly changes to the destination window. The
only problem is that the Perl variable $session_id doesn't get
replaced by the session ID value that $session_id contains. Because
of that, the front window information is incomplete. I tried escaping
the quotes in the URL, but Javascript didn't like that.
How do I get the variable to be replaced by the actual value, if
necessary using escape characters, but ones that Javascript won't
reject? There's an easy answer here, I hope--if someone can give me a
clue, I'd appreciate it!
Thanks, all,
--Eric
=====================
Eric L. Stedfeld
Info Tech Specialist
NYU Libraries
212 995-3545
eric.stedfeld@nyu.edu