Reputation: 29
I have 2 hyperlinks. I am aiming to target every hyperlink content to be displayed in a single page "result.html"
Example: Many to one -> Many hyper links content to one <.html> page
click hyper link1: ------> hyper link1's content in <result.html>
click hyper link2: ------> hyper link2's content in <result.html>
I tried using iframe, but no luck.
Could you please suggest where I went wrong.
Thanks & Regards.
Upvotes: 0
Views: 257
Reputation: 359
What about using a parameter? like this :
http://localhost/result.html?show=contentA
http://localhost/result.html?show=contentB
or use jquery to change element
So instead of loading a new page the link is change the element you want..
On below sample I will change the image on a webpage :
<img id="thechange" src="/images/test1.jpg"/>
the link is like this :
<button onclick="change('Test2.jpg')" value="Change2"/>
<button onclick="change('Test3.jpg')" value="Change3"/>
<button onclick="change('Test1.jpg')" value="Change1"/>
The script is like below :
<script>
function change(imageName)
{
$("#thechange").attr("src","/images/"+imageName)
}
</script>
Third option : Using pure css (copying the answer from here
Try using css like this :
.collapse{
cursor: pointer;
display: block;
background: #cdf;
}
.collapse + input{
display: none; /* hide the checkboxes */
}
.collapse + input + div{
display:none;
}
.collapse + input:checked + div{
display:block;
}
Html part :
<label class="collapse" for="_1">Collapse 1</label>
<input id="_1" type="checkbox">
<div>Content 1</div>
<label class="collapse" for="_2">Collapse 2</label>
<input id="_2" type="checkbox">
<div>Content 2</div>
Hope this is what you need
Upvotes: 1
Reputation: 668
Let's say that you have two anchor elements in the same page result.html
<a href="">Go To A Content</a>
<a href="">Go To B Content</a>
And you need to click on Go To A Content
to jump to a <div>
element with content A and click on Go To B Content
to jump to a <div>
element with content B.
<div>
element an id=""
<div id="content_a"> .... </div>
<div id="content_b"> .... </div>
<a href="#content_a">Go To A Content</a>
<a href="#content_b">Go To B Content</a>
This should do the mission.
I hope this is informative and have a happy code.
Upvotes: 0