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
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript if... statement.

    I'm very new to javascript in general, but here's what I'm looking to do:

    I have a navigation link ("galleries") that 'onclick' displays a sub-menu of other links (the specific galleries).
    This is on the home page of my site.
    When a user first views the home page, the sub-menu does not display, until they click "galleries".

    On other pages of my site, the "galleries" link is one of the options in my navigation. That link takes users back to the home page which is what I want it to do.
    But what I'm looking for to happen is if the user is directed back to the home page from within another page on my site, I'd like the link on the homepage to automatically display the sublinks under the "gallery" link.
    This is so that users don't have to click "galleries" twice in order to see the submenu.

    For example: If a user is on the 'about me' page, in the navigation there is a 'galleries' link. If they click it, it takes them to the home page. They would then have to click on 'galleries' again on the home page in order to display the sub-menu of individual galleries.
    I want them to show up immediately, but only when directed back to the home page from within my site.


    I think I do that with an 'if' statement, but I'm not sure of the syntax.
    I know that's a bit wordy and a little round about but I hope you can understand what I mean. Feel free to ask any questions if I can clarify something for you.

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    it's probably quite doable, although you'd need to specify how the pages navigate between each other and what triggers the menu opening.

    probably easier if you provide a link to your page, really...

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post
    Code:
    if(document.referrer.indexOf('YOUR SITE') && document.referrer != 'YOUR HOME PAGE'){
    	//Code that expands galleries
    }
    Fill in the blanks.

  • #4
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perfect! Thank you so much!


  •  

    LinkBacks (?)


    Posting Permissions

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