View Full Version : How to call a Server Side Include using a cookie

02-21-2003, 09:29 PM
I have a cookie which checks a count and needs to load a js file into the header if certain conditions are met, otherwise don't load the file.
I tried to use # include within the script but that sets an error.
Thanks In Advance!

Here is a partial example:

function checkCount() {
var count = GetCookie('tfe_count_js');
if (count == null) {
SetCookie('tfe_count_js', count, exp);

// If the script makes it here I want to load an external js file into the HEAD of the page
<!--#include file="jscript/cookietest.js" -->

else {
SetCookie('tfe_count_js', count, exp);

Roy Sinclair
02-21-2003, 10:13 PM
You have made a fundamental mistake here, you are trying to mix "Server Side" activities (such as a "Server Side Include") with "client side" activity, ie. the javascript. You either need to use a server side scripting language to check for the cookie at the server and include the appropriate content or use a client side method of adding the additional code (in this case it would be to document.write another <script> tag to bring in the desired script.