...

View Full Version : Printing from inside the iframe



Erindesign
10-29-2008, 07:17 PM
I have an iframe which needs to be printed. What is the proper way of printing the inside content of the iframe, through a link Inside this iframe?

Thx,
Erind

dustywb
10-30-2008, 10:18 AM
I would assume that you'd have to do it from inside the iframe. you could just add:
<a href="javascript:window.print()">Print Me</a>
to the iframes page and that should work

itsallkizza
10-30-2008, 04:12 PM
I tried this really fast because I was interested to see if you could print from outside the iframe:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Example</title>
<script type="text/javascript">
<!--
function printFrame(n)
{
if (document.getElementById(n).print) document.getElementById(n).print();
else if (window.frames[n].print) window.frames[n].print();
else if (top.frames[n].print) top.frames[n].print();
}
// -->
</script>
</head>
<body>

<a href="javascript:printFrame('my_iframe')">Print iframe</a>
<br /><br />
<iframe name="my_iframe" id="my_iframe" src="http://www.google.com"></iframe>

</body>
</html>


What I found:
- the DOM object reference doesn't contain a print function
- the frames array reference does contain a print function, but I get "Access Denied" in IE and "Permission Denied" in FF, which makes sense

Looks like you'll need to add the link to the iframed page itself (as dusty suggested).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum