emanuelle
05-19-2009, 10:11 AM
I have a js script that creates a print version for all my pages.
I add an ID where there is content and this is what I will see on the print versio page.
Now the problem is: I want to print 2 elements from my page.
I get some error
Can someone look at it pls and help me out
ORIGINAL CODE:
<script>function print1() {
var pre='<html><head>' +
'<style>body, div, table{font-family : arial ; }</style>' +
'</head><body>'
var post="</body></html>"
var gwin=open('print.html','hi','width=730,height=500,menubar,scrollbars')
var obj = pre + document.getElementById("scroll1").innerHTML + post ;
gwin.document.write(obj) ;
gwin.document.close() ;
gwin.focus
}
</script>
<div id="scroll1">text to be printed</div>
<a href="Javascript:print1()" > Print Version</a>
now I want to add another id to another div cause I also want it to be printed.
I did this but it doesnt work:
<script>function print1() {
var pre='<html><head>' +
'<style>body, div, table{font-family : arial ; }</style>' +
'</head><body>'
var post="</body></html>"
var gwin=open('print.html','hi','width=730,height=500,menubar,scrollbars')
var obj = pre + document.getElementById("scroll1").innerHTML + post ;
var obj = pre + document.getElementById("scroll2").innerHTML + post ;
gwin.document.write(obj) ;
gwin.document.close() ;
gwin.focus
}
</script>
<div id="scroll2">image to be printed</div>
<div id="scroll1">text to be printed</div>
<a href="Javascript:print1()" > Print Version</a>
WHAT IS WRONG WITH IT??
I add an ID where there is content and this is what I will see on the print versio page.
Now the problem is: I want to print 2 elements from my page.
I get some error
Can someone look at it pls and help me out
ORIGINAL CODE:
<script>function print1() {
var pre='<html><head>' +
'<style>body, div, table{font-family : arial ; }</style>' +
'</head><body>'
var post="</body></html>"
var gwin=open('print.html','hi','width=730,height=500,menubar,scrollbars')
var obj = pre + document.getElementById("scroll1").innerHTML + post ;
gwin.document.write(obj) ;
gwin.document.close() ;
gwin.focus
}
</script>
<div id="scroll1">text to be printed</div>
<a href="Javascript:print1()" > Print Version</a>
now I want to add another id to another div cause I also want it to be printed.
I did this but it doesnt work:
<script>function print1() {
var pre='<html><head>' +
'<style>body, div, table{font-family : arial ; }</style>' +
'</head><body>'
var post="</body></html>"
var gwin=open('print.html','hi','width=730,height=500,menubar,scrollbars')
var obj = pre + document.getElementById("scroll1").innerHTML + post ;
var obj = pre + document.getElementById("scroll2").innerHTML + post ;
gwin.document.write(obj) ;
gwin.document.close() ;
gwin.focus
}
</script>
<div id="scroll2">image to be printed</div>
<div id="scroll1">text to be printed</div>
<a href="Javascript:print1()" > Print Version</a>
WHAT IS WRONG WITH IT??