raviprakashg Posted May 5, 2006 Share Posted May 5, 2006 Dear Friends,I Got a Problem in Printing an Web Page, I have to Print Only a part of an web page (ie Only data in <Div>) its possible in JS? if So Please Help Me.thks hav gud dayurs raviprakash Link to comment Share on other sites More sharing options...
scott100 Posted May 5, 2006 Share Posted May 5, 2006 I would use css for this.here's a quick example <head><style>@media Print{p{ display:none }}</style></head><body><p>i will not print</p><div>i will print</div></body> Link to comment Share on other sites More sharing options...
raviprakashg Posted May 8, 2006 Author Share Posted May 8, 2006 sorry, i can't get u pls. explain more Link to comment Share on other sites More sharing options...
Nakor Posted May 8, 2006 Share Posted May 8, 2006 @media Print refers to anything that has to do with printing. Then if you go down into the stylesheet you see what's he's done. He does normal CSS by defining P, the paragraph tag (<p>), and then sets it's properties to display:none, making it not show up. So this means that anything with a <p> tag around it will not print, as opposed to the text with the <div> tag around it, which will print. You can make this easier by defining classes. <style>@media Print { .noprint { display:none; }}</style><p class=noprint>I won't print</p><p>I will print</p><div class=noprint>I also won't print</div><div>But I will</div> Anything that you define as the noprint class won't print. Link to comment Share on other sites More sharing options...
raviprakashg Posted May 10, 2006 Author Share Posted May 10, 2006 thanks for ur reply, whether the code will send the data to printer or provide the style to the selected section, if it prints means how to call it into a button, B'cos i want it to print clicking the button(Print Button) Link to comment Share on other sites More sharing options...
Webworldx Posted May 10, 2006 Share Posted May 10, 2006 I'm wondering if you can use execCommand('Print',0) on top of scott's solution for this. It'd be IE only though. Link to comment Share on other sites More sharing options...
scott100 Posted May 10, 2006 Share Posted May 10, 2006 Is this what your wanting <input type="button" value="print" onclick="window.print()" /> Link to comment Share on other sites More sharing options...
remarc duo Posted May 10, 2006 Share Posted May 10, 2006 Dear Friends,I Got a Problem in Printing an Web Page, I have to Print Only a part of an web page (ie Only data in <Div>) its possible in JS? if So Please Help Me.thks hav gud dayurs raviprakash<{POST_SNAPBACK}> 30 second reply. My team have used these typically when printing pages with many absolute divs. 1. grab the innerHTML (there's an example to show it going to a button). Example use <div id=p1> to get by id , or get the object the users click (also example) which element clicked Put in a <div> in a new window . user can print that 2. Insert a blank <div > at document start (top:0). Move <div> to print using position:absolute to start. Tell user to print first page.BUT containment issues. Are these for your sites or off the web. ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now