Change iframe src by clicking a link

后端 未结 2 1586
日久生厌
日久生厌 2020-12-05 15:14

I have an iframe that looks like this:




        
相关标签:
2条回答
  • 2020-12-05 15:36

    You don't need jQuery for that. You don't even need JavaScript for that.

    Give your iframe a name, and target your anchors to point to it:

    <a href="foo.html" target="myiframe">Foo</a>
    <a href="bar.html" target="myiframe">Bar</a>
    <a href="baz.html" target="myiframe">Baz</a>
    
    <iframe name="myiframe"></iframe>
    

    This degrades nicely for people who have JavaScript turned off.

    0 讨论(0)
  • 2020-12-05 15:50

    on clicking in the link "click here" // it will take move the link to the iframe as specified....

    <a href="cart.html" target="test" onclick="document.getElementById('test').frameBorder=1"> Click Here </a>
    <iframe src="blank.html" frameborder="0" name="test" id="test" width=1200 height=800></iframe>
    
    0 讨论(0)
提交回复
热议问题