SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Toggle visibility after a link is followed

    Hi there! I would REALLY appreciate any help!

    I've got a script that toggles the visibility of a div on "dashboard.html":

    Code:
    $(document).ready(function(){
    
            $("#add_networks_wrapper, .remove_box").hide();
    	$(".toggle_add_networks").show();
    	
    	$('.toggle_add_networks').click(function(){
    	$("#add_networks_wrapper, .remove_box").slideToggle();
    	});
    
    });
    On "dashboard.html" it works great. The div "add_networks_wrapper" is hidden until I click the link that toggles it.

    What I need is a link from a different html page (say "account.html" or whatever) to open "dashboard.html" with the hidden div's visible.

    Any help would be very appreciated!

  2. #2
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An idea:

    What if I had a link like "dashboard.html/user?trigger=true

    Can I use jQuery to look for the "trigger" element, and if the trigger is true in the address bar activate the script?

  3. #3
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes that's one way of doing it.

    But if you only need a "toggle" flag in the url's query string it might be easier to just have a single value in the ur's query string and then check if that value is there when the page loads.

    Something like this:

    In account.htm have a link with a href of dashboard.htm?trigger

    Then in dashboard.html check if the string "trigger" is in the url's query string and then act accordingly
    Code JavaScript:
    <script type="text/javascript">
     
        if(window.location.search.substring(1) == 'trigger') {
              // do this
        } else {
              //do that
        }
     
    </script>

    Having just a single value saves you having to parse the query string.


Bookmarks

Posting Permissions

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