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.
This works, just change the build page in the new window to suit your needs.
<html>
<head>
<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)
{ newWindow=window.open(“”,“xx”,“status=1,height=300,width=300”);
// delay writing to allow window to be created
setTimeout(“write2Window()”,100);
}
else
{ newWindow.focus();
}
}
// ---------------
function write2Window()
{ var build='<html>
<head>
<title>My Window</title>
‘;
build+=’<style type=“text/css”> #win1 {position:absolute; top:100px; left:100px; text-align:left; }
<\/style>
<\/head>
‘;
build+=’<body>
<div id=“win1”>
<p>This is your content<\/p><\/div>
<\/body>
<\/html>
';
newWindow.document.write(build);
newWindow.document.close();
}