?
Solved

print target javascript

Posted on 2006-05-16
6
Medium Priority
?
487 Views
Last Modified: 2008-02-01
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?
0
Comment
Question by:fox_statton
  • 3
  • 3
6 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 16688629
Huh? What is a print_target?
0
 

Author Comment

by:fox_statton
ID: 16688839
Sorry,
You know in IE when your right click on a link it gives you the option to print target
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 16688912
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.getElementsByTagName('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('msgDiv').innerHTML='<pre>'+t+'</pre>'

</script>
</body>
</html>


0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:fox_statton
ID: 16689159
Hi,
Yes that seems to work with normal files (like html pages etc), but it doesnt work with PDFs, any ideas?


Thanks
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 16689462
Nope.

PDF is a tricky thing. It SHOULD work, but it seems IE does not hand over the print to acrobat.

Did you try it with the files online, because there is also the matter of the headers being sent
0
 

Author Comment

by:fox_statton
ID: 16690342
yup, I was trying it with files on a webserver (but the html page was on my local machine)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question