Jeff Erickson Jeff Erickson - 6 months ago 94
Javascript Question

Open an iframe in a new window with jQuery?

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!

Answer

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; 

});
Comments