Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can scripts be called with js rather than SSI?

Status
Not open for further replies.

RenoWV

Technical User
Mar 16, 2002
156
US
Some cgi scripts say that they require SSI to work -- an example would be one that displays the number of visitors online at any given time. However if a person wants to incorporate that particular feature into existing pages, then it could be a real problem to have to rename everything with the .shtml extension.

Other scripts however say that they will work with either SSI OR javascript. So my question is:

Can most cgi scripts that say they require SSI be made to work equally well with js if a person follows a format similar to the second one below (adding the "?js" to the end):

SSI format:
Code:
<!--#exec cgi ="/cgi-bin/visitors.cgi" -->

javascript:
Code:
<SCRIPT SRC="[URL unfurl="true"]http://your-website.com/cgi-bin/visitors.cgi?js"></SCRIPT>[/URL]

Or will that technique only work if the flexibility is actually built into the original perl coding itself??

Thanks for any feedback...
 
Code:
<script language="javascript" src="/cgi-bin/myscript.pl?param1=fred&param2=Barney></script>

works for me, the important thing is to remember your content type header
Code:
print "Content-Type: text/javascript\n\n";

Word of warning, it can be a right PITA to debug

HTH
--Paul
 
Thanks very much Paul -- that is exactly the kind of advice I was hoping for...
 
If you're using this on every page on your site (i.e. there won't be an additional overhead in parsing pages that don't use SSI) then, depending on the server setup, you can have .html pages parsed for SSI too.
Create a .htaccess file with the following line:
Code:
AddHandler server-parsed .html
BTW - I'm assuming the server is apache.
 
Thanks very much ishnid. I had looked into this approach at one point but was told by my web host tech support that it would put a "much greater load" on the server. Don't know whether or not that's accurate however, as it's not my field, but just to be safe, decided to check out other options...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top