Reputation: 3883
I have a page embedded with an iframe in a Wordpress post, and I want to add a link in the iframe that, when clicked, will open that iframe's html page in a new window. I want to be able to do this without knowing the URL of that iframe. Is this possible? Thank you!
Upvotes: 0
Views: 17972
Reputation: 836
No need for jQuery. You can use JavaScript to get the src of the iFrame using the ID.
function popOut() {
var src = document.getElementById('popOutiFrame').src;
window.open(src);
}
Next, call the Script with a button
<button type="button" class="close" data-dismiss="modal" onclick="popOut()">
<!--Optional: Font Awesome expand icon-->
<i class="fa fa-expand" aria-hidden="true"></i>
</button>
<iframe id='popOutiFrame' src='http://example.com'></iframe>
Upvotes: 0
Reputation: 23208
Open window using window.open. you can set height, width and other properties of child window. jsfiddle.
<a href='javascript:void(0)' onClick="window.open(location,'_blank','width=800, height=900'); return false;" >Html name </a>
jQuery:
$('a').click(function(){
window.open(location,'_blank','width=800, height=900');
return false;
});
Upvotes: 1
Reputation: 457
In jquery you just could pass the iframe's src value in an javascript window.open():
window.open($("iframe.test").attr("src"), "Window Title", "width=300,height=400,left=100,top=200");
Upvotes: 1
Reputation: 5356
Try this
<a href='pathofhtml' target=_blank >Html name </a>
Upvotes: 0