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:
outputting html that includes javascript

 



splendidbob
Deleted

Jun 12, 2000, 5:01 PM

Post #1 of 2 (347 views)
outputting html that includes javascript Can't Post

Hello,
does anybody know if you can output javascript within html? - i need my perl script to output a page, but then redirect to another page - i figured using javascripts location could do this for me. But i dont know how to do the quotes - e.g. <script language="JavaScript") - i am not even sure if javascript here will work.
i need to relocate because otherwise the page will load inside a hidden frame!

Thanks
splendid bob


TheGame+
Deleted

Jun 13, 2000, 2:38 AM

Post #2 of 2 (347 views)
Re: outputting html that includes javascript [In reply to] Can't Post

Sounds like your design is a bit weird...
If I understand correctly, you have a hidden frame pointing to some CGI script, and you want that CGI script to print out some JavaScript to change the location of the parent frame ?

Anyway, let's handle your questions in the original order :

1) output javascript within html

Sure, just like any other text you'd like to print out. If you use individual print "..."; statements, you need to replace any " inside your text by \".
For longer texts, it's easier to use 'here' documents or the qq() statement :
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

# print everything up to the EOT mark
print <<EOT;
blah
<script language="JavaScript">
this is $myvar
EOT
# this needs to start at the beginning of the line, and may not contain spaces etc.
</pre><HR></BLOCKQUOTE>

2) redirecting to another url

In general, you'd use the redirect() method of the CGI module for this.
But that will only redirect the current frame, of course. So you wouldn't use that in this case - just print out the relevant JavaScript and let the browser handle the change of the parent frame.

3) let some javascript code in a sub-frame change the location of the parent frame

A window.location = '...'; would do the trick, maybe ? Look it up on some JavaScript site Smile

 
 


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

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