-1

I've been searching and searching and for some reason I cannot figure this out as simple as it probably is.

I am trying to link a logo from a list on a home page and connect it to the full details related to it on a separate page. The full details on the separate page are in a carousel being controlled by data targets, How can I link the logo from the home page to the specific data target on the full details page?

soundevour
  • 13
  • 3

2 Answers2

0

If I understand the question, assuming the logo is displayed in an <img> tag, try wrapping an anchor tag around it with an href like so

<a href="/linkToDetails"><img src"myImg.jpg></a>

Andrew Heekin
  • 671
  • 1
  • 6
  • 15
  • yes I have added the an a tag around the img tag after that it was a matter of linking it to the other page and then to a specific data target – soundevour Jun 13 '17 at 23:32
0

The best method would be to add a hash for the anchor tag to your url, and then use javascript to read the hash and then scroll to it! Here's a duplicate question with an answer that successfully accomplishes the effect jQuery scroll to ID from different page

marcx
  • 168
  • 1
  • 8
  • using a hash and an id doesn't work for it it will bring up the page but not that specific section. An on that page the sections aren't all displayed at once, it acts like a carousel just without any animation (hide/show) it has a banner of the logos above it and clicking a logo changes the section below it. trying to link to the specific sections. – soundevour Jun 13 '17 at 23:36
  • So make your `click`, this should make your url `http://yoursite.com/about.html#specificsection` AND change the page to `about.html`. Now, on `about.html`, with a little jquery you use `var hash = window.location.hash;` to pull `#specificsection` from url, and then `scrollTop: $(hash).offset().top`. It's a bit hacky, but it works. Wrap that in an `if(hash){}` to only fire if there is a hash, and you should be successful! Here is some documentation for the jquery scroll animation: https://www.w3schools.com/jquery/css_scrolltop.asp – marcx Jun 13 '17 at 23:59
  • Lots of others have run into the same problem https://stackoverflow.com/questions/9652944/jquery-scroll-to-id-from-different-page, edit those answers down to do what you need. Cut and paste can't help you all the way! – marcx Jun 14 '17 at 00:00
  • Hey hacked together is fine with me as long as it works, I'm sure I can Frankenstein something together from here, Thanks for the help! – soundevour Jun 14 '17 at 02:42
  • I am having some luck so far, I am able to get the hash from the URL perfectly fine, I see way that I can use the existing jquery that runs the slides via .hide / .show, but to do so i would have to take the hash variable remove the has and replace it with a period ex. "#m2" > ".m2" and i can for the life of me remember how to change/append a string – soundevour Jun 14 '17 at 03:38
  • That's great! I assumed you would be navigating to an id, so that the hash wouldn't have to change. To get just the string without the #, you can use `window.location.hash.substring(1)` instead of `window.location.hash`, and then to add the period you can simply do `'.' + hash`, which should end up with `.m2`. Let me know if that works! – marcx Jun 14 '17 at 05:57