0

How can I redirect from a different page to a page that has hidden sections which can only be visible once they are clicked?

I have two pages. One page has 4 full viewheight sections (3 hidden at all times) and other is just a page with content. The former page has a sidebar that makes the sections visible on click. I want to redirect from the second (content) page to one of those sections but I feel the I am unable to as that section on the first page needs to be clicked in order to make active.

//Function for switching tabs on the first page
var navigate = function(e) {
        var currentAttrValue = $(this).attr('href');        
        // Show/Hide Tabs
        $(currentAttrValue).addClass('active').fadeIn().siblings().hide().removeClass('active');
        // // Change/remove current tab to active
        $(this).addClass('highlighted').siblings().removeClass('highlighted');
        e.preventDefault();
}

The section I am trying to access has a 'display:none' property by default. I am looking for something that upon clicking from the source page makes the 'display: active' for the particular section on the target page and redirects. Sorry if I didn't frame my question better earlier.

  • This code itself means nothing. – Cesar Jr Rodriguez Jan 06 '19 at 01:28
  • 1
    Assuming you have full authorship capabilities on both pages you could read a URL param when your target page is loaded. From your source page, pass that URL parameter in the hyperlink to trigger the section to open in your target page. – Marc Jan 06 '19 at 01:29

1 Answers1

0

Branching directly off Marc's comment, you can get a pretty good idea of how to get the URL parameter from this question: Get url parameter jquery Or How to Get Query String Values In js

In the linked answer, a function is created to get the URL param. The idea would be, in the first page, to add the parameter directly in the link to the second page. I will assume that the page 1 link looks like:

https://www.your-site.com/page1?section=2

With the getUrlParameter function in the second page you could do something like:

var sectionToOpen = getUrlParameter('section');

Once you got the value, you can do your whatever condition is required to open up the specific sections.

Cesar Correchel
  • 513
  • 3
  • 7
  • Hi Cesar, thanks for the answer. I tried this but it didn't work. The section I am trying to access has a 'display:none' property by default. I am looking for something that upon clicking from the source page makes the display: active for the particular section on the target page and redirects. Sorry if I didn't frame my question better earlier. – Ayush Sharma Jan 08 '19 at 18:25