简体   繁体   English

单击一个<a>并将该innerHTML插入另一个HTML页面</a>时如何获取innerHTML <a>?</a>

[英]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?我尝试使用 .innerHTML 获取 div 中的每个值,但是如何将这些值“发送”到另一个 HTML 页面?

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".你可以在这里看到我想要的东西: http : //madebymorro.com/web_majosecastano/nieve.html这是图片库,只有 1 个项目处于活动状态,第一个在“2008”下。 You can see that when you click on it, a detail page opens: http://madebymorro.com/web_majosecastano/detalle.html您可以看到,当您单击它时,会打开一个详细信息页面: 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.我希望详细信息页面填写来自厨房 HTML 页面的信息。

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当您单击任何画廊项目时,将您的页面转换为 php 并仅创建一个详细信息页面,并在标签中传递该画廊的 id 或标题,并使用 url 查询参数或任何其他方法访问该 id

   <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并在 detail-page.php 中使用查询参数访问 id,然后使用 id 访问结果并在详细页面中打印

To access id using query parameter add code in detail page like this要使用查询参数访问 id,请在详细信息页面中添加代码,如下所示

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

here you will get gallery id在这里您将获得画廊 ID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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