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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IE7 JavaScipt Cookie from protected directory

    I use the Deconcept swfObject JavaScript method to dynamically embed Flash content on my site (serving alternative content when required etc.)

    I added something to the script so that it first looks for a cookie on the visitor's computer to determine whether they have elected to view Flash content or not. If it finds the cookie it shows the non-Flash content.

    This has been working fine for several years and still does - example: http://www.pennymachines.co.uk/Museum/Allwins-1.shtml
    (Click red Flash icon to hide Flash)

    However, a problem arose when IE7 arrived. BUT it only affects pages that are served from a directory which is protected by a Perl script (membership subscriber pages).

    If you want to check this out use the temporary Username and Password - codingforums and visit this page: http://www.pennymachines.co.uk/.Arena/CSI-1.shtml

    IN IE7 you get a "JavaScript required for slideshow" message in the middle of the page (plus alternative content).
    Notice - it does not effect the Flash navigation on the left, just the protected page in the main frame.
    In Firefox you'll get the Flash slideshow as intended.

    The problem seems to be with the cookie retrieval because if I remove that from the script it works fine.

    Sounds complicated, I know. I'm just a JavaScript muddler - so maybe someone who understands this stuff can suggest a possible cause or cure.

    Here's the JS I added to swfObject:

    //Flashtoggle begins
    function makeCookie(name, value, expire) {
    document.cookie = name + "=" + escape(value)
    + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
    }
    function getCookie(Name) {
    var search = Name + "="
    if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) {
    offset += search.length
    end = document.cookie.indexOf(";", offset)
    if (end == -1)
    end = document.cookie.length
    return unescape(document.cookie.substring(offset, end))
    }
    }
    }
    function flashOff(name) {
    var today = new Date()
    var expires = new Date()
    expires.setTime(today.getTime() + 1000*60*60*24*365)
    makeCookie("flashtoggle", name, expires)
    }
    function flashOn(name)
    {
    flashOff(name,"",-1);
    }
    var cookie1 = getCookie("flashtoggle");
    //Flashtoggle ends



    And in the HTML:

    <p id="flashcontent">my non-Flash content</p>
    <script type="text/javascript">
    if (cookie1 != "flashtoggle"){
    // <![CDATA[
    var so = new SWFObject("slideshow.swf", "slideshow.swf", 390, 540, 6,0,29,0);
    so.write("flashcontent");}
    // ]]>
    //--></script>

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Change this
    Code:
    <script type="text/javascript">
    if (cookie1 != "flashtoggle"){
    // <![CDATA[
    var so = new SWFObject("slideshow.swf", "slideshow.swf", 390, 540, 6,0,29,0);
    so.write("flashcontent");}
    // ]]>
    //--></script>
    to this
    Code:
    <script type="text/javascript">
    if (cookie1 != "flashtoggle"){
    var so = new SWFObject("slideshow.swf", "slideshow.swf", 390, 540, 6,0,29,0);
    so.write("flashcontent");
    }
    </script>
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks for your reply.

    I've updated the page to match your code, but sad to report, it made no difference.

    It's very odd that it works fine on Firefox and IE6 (I believe) and it also works fine in IE7 from all directories of my site except this password protected one.


  •  

    Posting Permissions

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