简体   繁体   中英

How to get innerHTML when clicking an <a> and inserting that innerHTML on another HTML page?

I have an image gallery, each gallery item has the picture, a title, and description. I want to be able to click on any of these gallery items and have a "detail" page load and fill in dynamically the image, title, and description. How can I do this?

I tried getting each of the values inside the divs with.innerHTML, but how do I "send" these values to the other HTML page?

You can see exactly what I want here: http://madebymorro.com/web_majosecastano/nieve.html This is the image gallery, only 1 item is active, the first one under "2008". You can see that when you click on it, a detail page opens: http://madebymorro.com/web_majosecastano/detalle.html

This is what I want to achieve, but not having to create a detail page manually for each one of the image gallery items. I want the detail page to fill in with the info coming from the galley HTML page.

Thanks!!!

Convert your pages into php and create only one detail page when you click on any gallery item pass the id or title of that gallery in tag and access that id using url query parameter or any other method

   <div class="row">
<div class="col-md-4">
<div class="gellery-block">
<a href="detail-page.php?id=1">
<img src="random-img.jpg"></img>
</a>
</div>
<div class="col-md-4">
<div class="gellery-block">
<a href="detail-page.php?id=2">
<img src="random-img.jpg"></img>
</a>
</div>

<div class="col-md-4">
<div class="gellery-block">
<a href="detail-page.php?id=3">
<img src="random-img.jpg"></img>
</a>
</div>
</div>

and in detail-page.php access id using query paremeter and then access result using id and print in detail page

To access id using query parameter add code in detail page like this

<?php $galleryId= $_GET['id']; ?>

here you will get gallery id

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM