Jump to content

Expand Text Block On Linked Page?


Guest Nova706
 Share

Recommended Posts

Guest Nova706

I know how to use javascript to expand blocks of text in HTML, basically passing a variable to rewrite a div to be display: block instead of display: none. However, I would like to have a link from one page that opens a second page and expands a text block on that second page.For example:On my about.html page, I have two expanding text blocks. I would like to have a link that navigates from my default.html page to my about.html page and expands the second text block on the about.html page.I believe this has to do with passing a javascript variable (to tell which block to expand) and calling a function on another page through a link... neither of which, I know how to do. Any help or resources would be welcomed. Thanks!

Link to comment
Share on other sites

One method:pass the data to the second page in a query string, then use the location.search property to get the query string. You'll have to handle the question mark, but that is not hard.So a link might look like this:<a href="page.html?product_2">Show me Product 2</a>And then the script on page.html would examine location.search, which in this case would equal "?product_2" ;location.search.substr(1) is even better, since it equals "product_2" -- if "product_2" is the id of your hidden div, the rest is easy.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...