We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,220 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

I cant print the contents of my div in mozilla

guys please help me how can I print the contents of my div in mozilla because it runs properly in opera mini and google chrome, well actually it still prints but the only content is "undefined" instead of the real contents of the div
this is my codes

<head>
<script type="text/javascript">
<!--
function printDiv() 
{ 
  var divToPrint=document.getElementById('content'); 
  var newWin=window.open('','Print-Window','width=100,height=100'); 
  newWin.document.open(); 
  newWin.document.write('<html><body onload="window.print()">'+content.innerHTML+'</body></html>'); 
  newWin.document.close(); 
  setTimeout(function(){newWin.close();},10); 
 }
//-->
</script>
</head>

<div id="content">
(contents)
</div>
<input name="button" type="button" onClick="printDiv()" value="print" />
2
Contributors
4
Replies
16 Hours
Discussion Span
1 Year Ago
Last Updated
5
Views
Ctechnology24
Junior Poster in Training
63 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

I would suggest using CSS for this.

http://www.w3schools.com/css/css_mediatypes.asp

stbuchok
Practically a Posting Shark
876 posts since May 2011
Reputation Points: 138
Solved Threads: 124
Skill Endorsements: 2

Sorry because I am new in javascript, thats why I cant understand how to integrate that @media function in my work :( can you give me some hints how can I apply that in my current codes?

Ctechnology24
Junior Poster in Training
63 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

You don't need javascript, you need to use CSS. Read the link I gave you.

stbuchok
Practically a Posting Shark
876 posts since May 2011
Reputation Points: 138
Solved Threads: 124
Skill Endorsements: 2

Help! now it wont work anymore, all browsers give me "undefined" as a result

Ctechnology24
Junior Poster in Training
63 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0682 seconds using 2.66MB