Reputation: 1357
I am using iframe you-tube video in my website.
Sample Code:
<iframe width="414" height="270" src="samplecode" frameborder="0" allowfullscreen></iframe>
If I click the youtube video it will redirect to the external page. I used the below code.
<a href="#"> <iframe width="414" height="270" src="samplecode" frameborder="0" allowfullscreen></iframe></a>
I know my way is wrong. It is not working. Please confirm to do this in anyway?
Upvotes: 0
Views: 1686
Reputation: 586
This will not work. To solve your problem you have to use javascript. For reference you can check following thread Detect Click into Iframe using JavaScript
Another Solution is
<div style="position:relative">
<div style="position:absolute;width:414px;height:270px" onclick='window.location.href="http://google.com"' ></div>
<iframe width="414" height="270" src="samplecode" frameborder="0" allowfullscreen></iframe>
</div>
Here I superimposed another div overiframe (we will not set any background for it, so iframe content will be seen) which will have onclick function which will take user to desired url
Upvotes: 1