CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Inserting JavaScript into perl source

 



deadroot
Deleted

Feb 5, 2000, 12:42 PM

Post #1 of 6 (904 views)
Inserting JavaScript into perl source Can't Post

Hello

I have some problem. How to insert java scripts into perl source ?
I need to insert Flycast code into source with the document.write command
Where is the problem?
It looks like this:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


document.write('<tr><td><!--Begin Flycast Ad Copyright 1999 Flycast Communications.');
document.write(' All rights reserved. Patent Pending -->');
document.write(' <SCRIPT LANGUAGE="JAVASCRIPT">');
document.write(' <!--');
document.write(' FlycastSite = "UnRealNetwork";');
document.write(' FlycastPage = "Remote";');
document.write(' FlycastWidth = 234;');
document.write(' FlycastHeight = 60;');
document.write(' FlycastPrintTag = true;');
document.write(' FlycastNewAd = true;');
document.write(' FlycastLoaded = false;');
document.write(' FlycastVersion = 3.5;');
document.write(' //-->');
document.write(' </SCRIPT>');
document.write(' <SCRIPT SRC="http://js-adex3.flycast.com/FlycastUniversal/" LANGUAGE="JAVASCRIPT"></SCRIPT>');
document.write(' <SCRIPT LANGUAGE="JAVASCRIPT">');
document.write(' <!--');
document.write(' if (FlycastLoaded) FlycastDeliverAd();');
document.write(' //-->\\n');
document.write(' </SCRIPT>');
document.write(' <NOSCRIPT>');
document.write(' <IFRAME WIDTH=234 HEIGHT=60 SRC="http://ad-adex3.flycast.com/server/iframe/UnRealNetwork/Remote/123456" scrolling="no" marginwidth=0 marginheight=0 frameborder=0 vspace=0 hspace=0>');
document.write(' <A target="_top" HREF="http://ad-adex3.flycast.com/server/click/UnRealNetwork/Remote/123456"><IMG BORDER=0 WIDTH=234 HEIGHT=60 SRC="http://ad-adex3.flycast.com/server/img/UnRealNetwork/Remote/123456"></A>');
document.write(' </IFRAME>');
document.write(' </NOSCRIPT>');
document.write('<!--End Flycast Ad Copyright 1999 Flycast Communications. All rights reserved. Patent Pending -->');
document.write('</td></tr></table>');
</pre><HR></BLOCKQUOTE>


brian.hayes
User

Feb 5, 2000, 6:38 PM

Post #2 of 6 (904 views)
Re: Inserting JavaScript into perl source [In reply to] Can't Post

Can you post the exact code unchange that you have.

Thanks,

Brian Hayes


deadroot
Deleted

Feb 6, 2000, 4:48 AM

Post #3 of 6 (904 views)
Re: Inserting JavaScript into perl source [In reply to] Can't Post

Hi.

The problem is, that I work on some perl script for offering free poll service.
The people who wants to have poll on there site will have to put something like this on their html page:
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


<script>
document.write('<script src="http://www.my_site.com/cgi-bin/freepoll/poll.pl?name=their_name><\/script>');
</script>
</pre><HR></BLOCKQUOTE>

This poll.pl is the perl script in what I wish to put Flycast code (which is exactly as I posted) and I have to use document.write in it.

Does this have some sense?

Thank you.


Cure
User

Feb 6, 2000, 10:58 AM

Post #4 of 6 (904 views)
Re: Inserting JavaScript into perl source [In reply to] Can't Post

Hi deadroot:

The reason why isnt not working is because you have javascript problems.
Some of your javascript code works on html but in Perl the entire code must work right to function.

Fix your javascript then it will work in perl.

Heres a example using javscript, in your case document.write in Perl.

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print qq~
<SCRIPT language="javascript">
document.write(' world = 200;');
</SCRIPT>
~;

Note: that it will print world = 200 to the browser if you want to use the world =200 in certain cases then you need to make it a function in javascript.


Cure
User

Feb 6, 2000, 10:03 PM

Post #5 of 6 (904 views)
Re: Inserting JavaScript into perl source [In reply to] Can't Post

Javascript is processed when the page is loading (or thereabouts) and
your perl program doesn't do much with it. When I use it and Perl
together it looks like:
--- cut here ---
print <<EOF;
<HTML>
<SCRIPT LANGUAGE=JAVASCRIPT SRC="http://www.netforge.net/cgi-bin/jtest.pl">
</SCRIPT>
<BODY>
</BODY>
</HTML>
EOF
--- cut here ---

Perl doesn't do anything with Javascript itself.

Cure



kencl
User

Feb 16, 2000, 3:54 PM

Post #6 of 6 (904 views)
Re: Inserting JavaScript into perl source [In reply to] Can't Post

It's too bad more people don't have PERL installed, then you could just write:

<script language="perlscript">...

Deciding the balance between running on the server (eg Perl, Python...) or the client (Javascript, CSS, DHTML...) can be a bit tricky. My rule of thumb is that if the client's environment has enough info to get the job done, that's where I do it.

Cure's solution looks perfect in this case.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives