Printing contents of a dynamically created iframe from parent window

Posted by certainlyakey on Stack Overflow See other posts from Stack Overflow or by certainlyakey
Published on 2009-05-06T18:56:47Z Indexed on 2012/12/10 17:03 UTC
Read the original article Hit count: 156

Filed under:
|
|

I have a page with a list of links and a div which serves as a placeholder for the pages the links lead to. Everytime user clicks on a link an iframe is created in the div and its src attribute gets the value of the link href attribute - simple and clear, sort of external web pages gallery. What i do have a problem with is printing the contents of the iframe. To do this i use this code:

function PrintIframe()  
{  
frames["name"].focus();  
frames["name"].print();  
}

The issue seems to be that iframe is created dynamically by JQuery - when I insert an iframe right into the html code, the browser prints the external page all right. But with the same code injected by JavaScript nothing happens. I tried to use JQ 1.3 'live' event on "Print" link, no success. Is there a way to overcome this?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about iframe