Code Comments
Programming Forum and web based access to our favorite programming groups.In my perl script I have put my javascript code in a separate file with the
extension of js. I reference it with a javascript tag in the HTML. I have
some code in there that is not in a procedure: it just executes prior to the
body of the page loading as inline statements.
Now I discover I need some of those URLs in my external javascript file to
change depending on some perl parameters.
This is not a procedure so I cannot just change some javascript procedure
parameters. Perl does not process this file so it won't do the variable
interpolation I want either.
Below is the code that is causing the problem.
I think the only way to resolve this is to cut the code below and move it to
the perl code where I can use interpolation (which I would prefer not to do
because it will really clutter up the main program -- oh well).
Can anyone suggest a better approach?
Thanks,
Siegfried
if (document.images) {
one_on = new Image ();
one_on.src = "http://www.decisionchannel.com/breturn2.gif";
one_off = new Image();
one_off.src = "http://www.decisionchannel.com/return2.gif";
two_on = new Image ();
two_on.src = "http://www.decisionchannel.com/f_bwhatbut2.gif";
two_off = new Image();
two_off.src = "http://www.decisionchannel.com/f_whatbut2.gif";
... // more of the same
}
Post Follow-up to this messageOn Mon, Nov 22, 2004 at 01:21:35PM -0700, Siegfried Heintze wrote: > In my perl script I have put my javascript code in a separate file with th e > extension of js. I reference it with a javascript tag in the HTML. I have > some code in there that is not in a procedure: it just executes prior to t he > body of the page loading as inline statements. > > Now I discover I need some of those URLs in my external javascript file to > change depending on some perl parameters. > > This is not a procedure so I cannot just change some javascript procedure > parameters. Perl does not process this file so it won't do the variable > interpolation I want either. > > Below is the code that is causing the problem. > > I think the only way to resolve this is to cut the code below and move it to > the perl code where I can use interpolation (which I would prefer not to d o > because it will really clutter up the main program -- oh well). > > Can anyone suggest a better approach? I'd suggest loading the js file using HTML::Template. Substitute the code yo u want with a <TMPL_VAR />, and write some logic so that if the query string contains foo.js (a slight oversimplification) that it loads that template, prints it, then exits. Does that make sense to you? Anyone else? -- ===================== Shaun Fryer ===================== http://sourcery.ca/ ph: 416-544-9461 =====================
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.