Reply
cgi/java query
Old 06-14-2002, 08:44 AM cgi/java query
Junior Talker

Posts: 2
Hi,
I`m trying to pull some java up from a cgi script, and I`m having problems, I`m guessing, so
how would i write -

<!-- if (navigator.appName == "Microsoft Internet Explorer"){ document.write("<a href=\"http://www.any.com/\" onClick=\"parent.Preview(this);return false\" class=\"nlg\"><b>PreviewThis</b></a>");}else{ document.write(" - ");}//-->


it needs to go inbetween -

print "<script language=JavaScript></script>";

and it does not work in it`s present format, what do you think is wrong, anybody?

Thanks

Mel
elmpie is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 06-14-2002, 04:24 PM Re: cgi/java query
Tiggy's Avatar
Ultra Talker

Posts: 250
Location: Lancashire, UK
I'm not into JavaScript as a rule, but I can tell you what is wrong with it... first of there might be problems if all of it was just the one line...

<!--
if (navigator.appName == "Microsoft Internet Explorer") {
&nbsp; &nbsp; document.write('<a href="http://www.any.com/" onClick="javascript:parent.Preview(this);return false;" class="nlg"><b>PreviewThis</b></a>');
} else {
&nbsp; &nbsp; document.write(' - ');
}//-->

Try that, I've bolded the changes (note that JavaScript is all one word but the board broke it up). I'm not sure which way around the single or double quotes go (i.e if it's single inside double or double inside single) - but it was the only thing obivious I could see that might cause a problem.
__________________
Web Site Owner's Resource - http://websiteowner.info
Tiggy is offline
Reply With Quote
View Public Profile Visit Tiggy's homepage!
 
Old 06-14-2002, 04:30 PM
Junior Talker

Posts: 2
Thanks Tiggy,
I`ll give this a play with,

Mel, appreciate it.
elmpie is offline
Reply With Quote
View Public Profile
 
Old 06-14-2002, 04:55 PM
Skilled Talker

Posts: 66
Location: British Columbia, Canada
When using quotes inside of quotes you have to do one the following:

instead of double quotes in javascript, use single quotes
or,
use the markup code for it likes this \"

Note: I do not use perl so I am assuming that the
PRINT statement also ends with a ; like javascript does.

In this example I have converted all quotes to \"

print "<script language=JavaScript>";
print "<!--";
print "if (navigator.appName == \"Microsoft Internet Explorer\") {";
print " document.write('<a href=\"http://www.any.com/\" ";
print "onClick=\"javascript:parent.Preview(this);ret urn false;\" ";
print "class=\"nlg\"><b>PreviewThis</b></a>');";
print "} else { ";
print " document.write(' - '); ";
print "}//--> ";
print "</script>";
wynpublishing is offline
Reply With Quote
View Public Profile Visit wynpublishing's homepage!
 
Reply     « Reply to cgi/java query
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12668 seconds with 13 queries