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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    408
    Thanks
    17
    Thanked 2 Times in 2 Posts

    extra snippet kills rest of js script.

    I have a working script that dies when I add in a separate component. Maybe Somebody can spot the problem?

    Here's the working script:
    Code:
    $(document).ready(function() {
    
    
    
    $(".footer-ul").css('display','none');
    
      $("#foot-nav-main").mouseenter(function(){
        // alert("hello");
        $(".footer-ul").css('opacity','0').css('display','block');
        $('#foot-nav-main,#footer-container').stop().animate({ height: 190 }, 300, function() {
        /* animation done */    
        });
        
        $(".footer-ul").css('display','block').stop().animate({ opacity: 100 }, 6000, function() {
        /* animation done */    
        }); 
      });
      
      $("#foot-nav-main").mouseleave(function(){
        
        $(".footer-ul").stop().animate({ opacity: 0 }, 220, function() {
          $(".footer-ul").css('display','none'); 
        });
        
        $('#footer-container').stop().animate({ height: 90 }, 400, function() { /* animation complete */ });
        $('#foot-nav-main').stop().animate({ height: 32 }, 400, function() { $(".footer-ul").css('display','none'); }).css({ overflow: hidden });
      });
    
      
    });
    But when I put this inside the document ready (or anywhere on the page), the js file stops working.

    Code:
    if (/\\?page=//.test(window.location)) {
    $(".newsthumb1, .NewsSummarySummary").css("display","none");
    };

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,302
    Thanks
    28
    Thanked 276 Times in 270 Posts
    Quote Originally Posted by turpentyne View Post
    I have a working script that dies when I add in a separate component. Maybe Somebody can spot the problem?

    Code:
    if (/\\?page=//.test(window.location)) {
    $(".newsthumb1, .NewsSummarySummary").css("display","none");
    };
    The delimiter character for regular expression literals is the forward slash (/). If you use that character within a regular expression, it needs to be escaped with a backslash (\); otherwise it'll prematurely end the expression and cause a syntax error.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Posts
    408
    Thanks
    17
    Thanked 2 Times in 2 Posts
    ahh.. ok..

    So it seems to work with this, adding a backslash after "page=".

    Code:
    if (/\\?page=\//.test(window.location)) {
    $(".newsthumb1, .NewsSummarySummary").css("display","none");
    };
    I don't need another after the second forward slash, do I? I'm having some server caching issues that are making verifying what works a little hard.

  • #4
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,302
    Thanks
    28
    Thanked 276 Times in 270 Posts
    Quote Originally Posted by turpentyne View Post
    I don't need another after the second forward slash, do I?
    No, the outer slashes are regular expressional literal delimiters. They're analogous to the double and single quotation marks which are string literal delimiters.

    Code:
    var regEx = /abc/; // Match "abc".
    
    // Non-Literal Equivalents:
    var regEx = RegExp("abc");
    var regEx = new RegExp("abc");
    Quote Originally Posted by turpentyne View Post
    I'm having some server caching issues that are making verifying what works a little hard.
    Use a browser extension like Cache Toggle (for Firefox) if you need to forcibly ignore the cache. Or use a test server with expires_module disabled if using Apache.
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

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