最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Open an iframe in a new window with jQuery? - Stack Overflow

programmeradmin5浏览0评论

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 0
Add a ment  | 

4 Answers 4

Reset to default 1

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; 

});

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>

Demo

发布评论

评论列表(0)

  1. 暂无评论