Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

problem with including external javascript file with start_html

by pitbull3000 (Beadle)
on Sep 04, 2001 at 14:38 UTC ( #110003=perlquestion: print w/replies, xml ) Need Help??
pitbull3000 has asked for the wisdom of the Perl Monks concerning the following question:

i include a external javascript file (ua.js) with
print $query->start_html(-title=>'Umgebungsvariablen auslesen', -script=>{-src=>'ua.js'});
in this javascript are some routines which are processed. if i write some static html and include this js file, all is well done, and i can access some of the variables defined in the ua.js file. but when creating the page on the fly with cgi, the routines are not processed and i couldnīt access the specific variables out of the js file. again if i include the javascript code into the perl script in some variable, and print this variable all goes fine. but i dont want to include all this js stuff into my perl code, also i dont want to open the js file during runtime of the script, and read the file into a variable... any ideas how to handle this thanks pitbull3000

Replies are listed 'Best First'.
Re: problem with including external javascript file with start_html
by Masem (Monsignor) on Sep 04, 2001 at 15:33 UTC
    One thing you should try to do when you have problems with what CGI puts out and what static HTML puts out is to save the output of the CGI as given to your browser, and do a hand comparison of both scripts to see what's present and what's missing in both. The CGI.pm documentation does notes that it will try to format the output to make certain browsers happy, and this might be causing your problem which will only show up in the actual output.

    -----------------------------------------------------
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
    It's not what you know, but knowing how to find it if you don't know that's important

Re: problem with including external javascript file with start_html
by George_Sherston (Vicar) on Sep 04, 2001 at 15:24 UTC
    I've just been using the same code for my own project, and what you have there works for me, so I can't suggest a positive solution. I know this doesn't help! Does the html that your cgi creates on the fly look the same as the static html that works? Or
    (1) Do you need to specifiy -language=>'JavaScript'? ... answer probably not, as in the current version of CGI.pm that is the default anyway.
    (2) Do you need -onload=>'your.function()' to run the js?

    Apart from that I can't think of anything helpful except to repeat that what you're trying to do does work, so there is a solution. Only I don't know it!

    § George Sherston
Re: problem with including external javascript file with start_html
by Corion (Pope) on Sep 04, 2001 at 15:30 UTC

    My solution to this problem is more like a hammer, I output something like this :

    print qq(<script src="lib.js"></script>)

    I admit that I haven't used CGI.pms ways of generating stuff in the HTML header much to be of help in that case.

      just stick to your suggestion, unfortunately i couldnt use the print start_html then, or i just put my script outside the head.... thanks guys
        Dont include your javascript file cgi-bin directory instead use any other folder outside of cgi-bin.
        include full path like http://localhost/perl_js/main.js
Re: problem with including external javascript file with start_html
by wardk (Deacon) on Sep 04, 2001 at 18:31 UTC
    Is this an issue with location?

    try hard-coding the full path to the file (from the web perspective, not filesystem).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://110003]
Approved by root
help
Chatterbox?
[perldigious]: A question since I'm ignorant of what's normal for database management... Do admins change column names a lot in databases?
[perldigious]: On occasion my scripts break, because they will do something that seems laregly pointless to me... like in this case, changing a column name from "ABC Category" to "ABC Category Override".
[perldigious]: Being the ignorant one, my initial reaction to that is, "that's sort of a dick move, a lot of people like me expect column names like that to stay the same, why the hell would you change them like that for seemingly no good reason?"
[perldigious]: Or is my irritation/ frustration well founded?
[Corion]: perldigious: That seems to be more the export and likely it's the recipients of that export that like the titles changes
[Corion]: ... "changed"
[Corion]: I usually expect fixed header names, but am sometimes lenient in the order of columns. But changing the report titles often sounds to me as if you are not the sole consument of the export ;)
[shmem]: perldigious: as always - if it ain't broke, don't fix it. Ther must be a very compelling reason for changing column names in a database. Those are rare.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2017-05-25 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?