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!
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!
Share Improve this question asked Sep 27, 2012 at 11:35 Jeff EricksonJeff Erickson 3,8938 gold badges39 silver badges45 bronze badges 04 Answers
Reset to default 1Open 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;
});
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");
Try this
<a href='pathofhtml' target=_blank >Html name </a>
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.'></iframe>