Print from a <div>

I am a designer new to javascript. I would like to open a specifiv div (with a specific id) in a new window. On this window I would like to attach a specific print stylesheet (css) and have a print button on the screen to print the screen. As I am new, I need detailed instructions and examples. I appreciate ay assistance.


Thais sounds good. How do i grab the html inside a <div> and place it in the new screen?

here’s an example:

<p>some text… Want to <a href=“‘/page2.html’, ‘Detail’, ‘width=300,height=150,status=yes,location=no’);”>read more</a>?

that div yuo want

This works, just change the build page in the new window to suit your needs.


<script type=“text/Javascript”>
var newWindow=null; // global
// open window and insert content
function buildPage()
{ // check to see if it already exists
if(!newWindow || newWindow.closed)
// delay writing to allow window to be created
{ newWindow.focus();
// ---------------
function write2Window()
{ var build='<html>
<title>My Window</title>
build+=’<style type=“text/css”>
#win1 {position:absolute; top:100px; left:100px; text-align:left; }
<div id=“win1”>
<p>This is your content<\/p><\/div>

<style type=“text/css”>
body { font-famil:arial; font-size:13px; font-weight:bold; color:#000; }
#firstPage { position:absolute; top:100px; left:100px; text-align:left; cursor: pointer; }


<div id=“firstPage” onclick=“buildPage()”>
<p class=“a”>Open new window</div>



Well, read this… since you have to give a source for the window, code it how you see fit.