fox_statton
asked on
print target javascript
Is there anyway to access the print target function from IE (eg print_target("http://www.x.com/file.doc") for example so that when a user clicks on an item they are offered the ability to print it?
Huh? What is a print_target?
ASKER
Sorry,
You know in IE when your right click on a link it gives you the option to print target
You know in IE when your right click on a link it gives you the option to print target
Yeeees? And when do you want to access that, how and why?
Do you mean this?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>print using link rel=alternate</title>
<link rel="alternate" href="test1.txt" media="print">
<script>
/* Print alternate prints using link
Copyright (c) 2003-2006 Michel Plungjan "javascripts at planet.nl" */
obj = document.getElementsByTagN ame('LINK' );
function changePrint(url) {
if (url) obj[0].href=url;
window.print();
return false;
}
</script>
</head>
<body>
<a href="test1.txt"
onClick="return changePrint('test1.txt')"> print test1.txt</a><br>
<a href="test2.html"
onClick="return changePrint('test2.html')" >print test2.html</a>
<div id="msgDiv"></div>
<script>
t="";
for (i in obj[0]) t+= '\n'+i+':'+obj[0][i]
document.getElementById('m sgDiv').in nerHTML='< pre>'+t+'< /pre>'
</script>
</body>
</html>
Do you mean this?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>print using link rel=alternate</title>
<link rel="alternate" href="test1.txt" media="print">
<script>
/* Print alternate prints using link
Copyright (c) 2003-2006 Michel Plungjan "javascripts at planet.nl" */
obj = document.getElementsByTagN
function changePrint(url) {
if (url) obj[0].href=url;
window.print();
return false;
}
</script>
</head>
<body>
<a href="test1.txt"
onClick="return changePrint('test1.txt')">
<a href="test2.html"
onClick="return changePrint('test2.html')"
<div id="msgDiv"></div>
<script>
t="";
for (i in obj[0]) t+= '\n'+i+':'+obj[0][i]
document.getElementById('m
</script>
</body>
</html>
ASKER
Hi,
Yes that seems to work with normal files (like html pages etc), but it doesnt work with PDFs, any ideas?
Thanks
Yes that seems to work with normal files (like html pages etc), but it doesnt work with PDFs, any ideas?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yup, I was trying it with files on a webserver (but the html page was on my local machine)