Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to call a Server Side Include using a cookie

    Hello,
    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) {
    count=1;
    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 {
    count++;
    SetCookie('tfe_count_js', count, exp);
    }
    }

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •