JavaScript - Printing Textual Data From Browser (window.print())
Hi,
Ours is a web based application. In a particular use case, print-receipt; we pull up data from database and display it a new window ... followed by a javascript::window.print() To print the content. But this prints the browser window - in graphic mode. The target printer, attached to the browser machine is a Dot matrix printer; and consumes a lot off time to print a single window (because of the graphic nature) Can the printing be done in text mode ? thank you. jeevan Similar TutorialsHey there, I've scrollable screen. I'm having a print button on it and "window.print()" function is called on its onclick event. My problem is it only prints the "viewable" part of the screen, not the whole screen. P.S. I'm using IE7 and it must work for IE7 atleast (for rest I'm not bothered). Thanks in anticipation. Hello gurus I have a page that needs to be printed 3 times. Window.Print() is such a great function, but I can't change the default number of pages to 3 with it. Is there anyway to do this? I was thinking maybe if it's a way not showing the print page at all, just printing after the button is hit, I could put it in a loop and print 3 times. Do you guys know of any remedy? Help this poor mortal in here Hi guys, hoping you can help me out again, with this new problem. I've got a form which is acting as a calculator. Once the calculation is complete I want it so when the user presses a 'print' button it takes certain parts of the form data and displays them in a new window which would be designed for printing. how can i go about this using only javascript? thanks Hi, I'm using window.print() to print a document. This is the coding : <th colspan="2" align="right"><a href="JavaScript:window.print();" onclick="return verify()"><img src="image/image.gif" width="25" height="20" /></a></th> How can i print the document without printing together the image? Or is there any other way that you guys know? Thanks I am looking to have a link open a closeable window that is contained within a browser window. If you click on the "sizing charts" link on this website, this is exactly what I am looking to do: http://www.bella.com/mapper.php?pageid=40 The window is contained within the current browser window, it can be dragged around, but not outside the parameters of the browser window. Is there a title for this technique that I can research? Not looking to waste anybodys time, but if I can get steered in the right direction it would be greatly appreciated. Thanks Hi Ive found out how to force another browser window to open at a certain size when a link is clicked. Here's the whole line of code including the layer, the javascript and the image, <div id="Layer6" style="position:absolute; width:10px; height:8px; z-index:6; left: 561px; top: 310px"><a href="javascript:;" onClick="MM_openBrWindow('navigation%20instructions.htm','','width=50,height=50')"><img src="images/info.gif" width="15" height="15" border="0"></a></div> How do I adapt this so I can also specify the x&y co-ordinates of the opened window relative to the window that launched it. thanks alot Masten I would like to create a print preview window that will display only the main content of the page that a person would really want to print. I found a script that didn't do that, but that I was able to adapt, somewhat. It doesn't fully work though and I can't get it any better. Here is what I have... <html> <head> <title></title> <script LANGUAGE="JavaScript"> function displayHTML(printContent) { var inf = printContent; win = window.open("print.htm", 'popup', 'toolbar = no, status = no'); win.document.write(inf); } </script> </head> <body> <div id="printarea">Print this stuff.</div> <a href="javascript:void(0);" onclick="displayHTML(printarea.innerHTML)">Print Preview</a> </body> </html> In mozilla it opens the new window but continues to be thinking about something indefinitly. In Safari the new window opens but there is no content. In IE it seems to work fine. I haven't tested NS yet, nor have I tested any of this on a PC. Thanks for any help. This should be a simple fix. I have a basic html form with some text input fields and a couple drop down selection lists. Our employees print the form and include it with items they need our shipping department to ship for them. The form uses the following verification script to ensure the required fields have been populated before the screen prints. It works exactly as desired in Safari and Firefox. In Internet Explorer, however, the selections made in the drop down lists are reset to the default values on the printed form. Before you respond with, "don't use Internet Explorer," you have to understand that Internet Explorer is our only corporate approved web browser because it is the only browser supported by some of our other "mission critical" third party web apps and because it can be more rigorously controlled using Group Policies than Safari, Firefox, Chrome, Opera, et al, can. Any advice on how to make the form print without resetting the drop down list selections? Code: <script language="javascript"> function verify() { var themessage = "You must provide the following information"; if (document.shipment.SenderName.value == "") { themessage = themessage + ", Sender Name"; } if (document.shipment.SenderEmail.value == "") { themessage = themessage + ", Sender Email"; } if (document.shipment.Dept.value == "") { themessage = themessage + ", Department"; } if (document.shipment.Contact.value == "") { themessage = themessage + ", Ship To Contact"; } if (document.shipment.Street1.value == "") { themessage = themessage + ", Ship To Street 1"; } if (document.shipment.City.value == "") { themessage = themessage + ", Ship To City / Locale"; } if (document.shipment.country.value == "") { themessage = themessage + ", Ship To Country"; } if (document.shipment.state.value == "") { themessage = themessage + ", Ship To State / Province"; } //alert if fields are empty and cancel form submit if (themessage == "You must provide the following information") { window.print(); return false; } else { alert(themessage); return false; } } </script> [help] i have the big problem,,, how script to make data to new window (after that, output can print) n data from previous window with datatables (datatables.net) and with default header n footer in new window??? case: [datatable] i search with datatable and have 3 record... and show in new window with default header n footer company , and in new window have function to print the record with header and footer. I hope, anybody can help me..Please thank you I am currently creating which will allow the user to upload their own pictures. For this I am opening a new pop up window where the user can select the file they wish and then upload it (similar to ebay's picture upload). The pop up works fine and so does the file upload however I am having trouble transferring any data from the pop up window back to the parent window. I have been investigating the opener method but cannot seem to get it to work. Below is some simple code that I've been trying to get to work... Thanks for any help! first page... Code: <form name="loadpic" id="loadpic" action="createPost.php" method="post"> <br /> <br /> Testing transfer between pages... <input type="button" value="open pop up" onclick="window.open('popup.php','pop up box','width=400,height=200')" /> <br /> <br /> <span name="myspan" id="myspan">text here</span> </form> pop up page... Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Pop Up</title> <script language=javascript> function transfer(){ opener.document.loadpic.myspan.innerHTML = "working"; window.close(); } </script> </head> <body> This is the pop-up page! <input type="button" onclick="return transfer()" value="press me" /> </body> I'm having trouble getting Google Chrome to print the correct content when I change the content of a modal page with JavaScript. This is my code: JavaScript: Code: function printCoupon(couponID) { var originalContents = document.body.innerHTML; var printable = document.getElementById(couponID); var printContents = printable.innerHTML; document.body.innerHTML = printContents; window.print(); document.body.innerHTML = originalContents; document.getElementById(couponID).scrollIntoView(true); } HTML: Code: <body> <div id="coupon1"><p>Coupon 1 contents</p></div> <div><a href="javascript:void(0)" onclick="printCoupon('coupon1');return false;">Print Coupon</a></div> <div id="coupon2"><p>Coupon 2 contents</p></div> <div><a href="javascript:void(0)" onclick="printCoupon('coupon2');return false;">Print Coupon</a></div> </body> This works in IE8 and FF 3.6, but Chrome 16 prints the original content, not the printable content. UPDATE: I just discovered another problem with this script. In IE9, the parent page is printed along with the modal (the modal looks transparent), instead of just the modal. Hi there, I'm absolute newbie in javascript, so the question may look not worth asking for you. Sorry for that. My situation is like that: I want to make a preview of form data using javascript. After the button "preview" is clicked I start showing div dialog which should contain data entered by users. The problem is that because my div dialog is coded in the same page as form I can get only default values. It means - after making some changes, they are not visible. To get and print the value of input I use this code: Code: <script type="text/javascript"> mytext = document.getElementById('name').value; document.write(mytext); </script> How it would be possible to update the values on "on click" event. Thank you very much for considering this question. Hello, First I want to say I have no experience with coding, I develop eLearning via Adobe Captivate. We recently implemented a new LMS from PeopleSoft. This new LMS is launching the eLearning in a small browser window probably 500x400 without the ability to resize this. I am wondering first, if it's possible to edit the htm/js file that Captivate produces, and if anyone is aware of code that could then be entered into the htm/js file to resize the browser upon launch? Thanks! hey guys im just building a portfolio website for my self and i wanted to create something that could work well across a number of devices and screen sizes. i recently came across this website http://tillwiedeck.com/ and noticed that the menu positions itself according to the size of the browser window. This works really well when viewing it on devices such as ipads and iphones. My question is that does anybody know if there is any way i could make an object always position itself at say 25% of the windows width and another object always position itself at 75% of the windows width. really hope i'm making myself clear. thanks heaps Hello, I was wondering if there is a way to prevent the browser window from scrolling when you are scrolling inside an overflow auto div and reach the end of the div's scroll? Right now I have a few people complaining about a div that loads scrolling info on the screen and when they scroll down using the mouse wheel and get to the bottom of the div then the rolling of the mouse wheel starts scrolling the browser window. It would be nice if the browser could see that your cursor is over the div and even though it reaches the end, not scroll the window unless you move the cursor outside of the div that you are currently scrolling. Any ideas or is this just something we have to deal with? Thanks Hi, this will probably make a bit more sense it you read my topic in the HTML section (http://www.codingforums.com/showthread.php?t=57093) where I had a problem with two floating divs, in the end the solution was to give both on my floating divs a fixed width. Now, the menu bar div will always be 150 pixels and i wanted the remaing width to be taken up by the main content div. This script here seems to work very wel in firefox but in ie I get scrollbars. This seems to be because firefox returns the actuall width of the viewing 'frame' while IE seems to give the width of the window itself. PHP Code: <script type="text/javascript"> onload = function getBrowserWidth() { if (!document.all) { var width = document.body.offsetWidth; var newWidth = width - 150; document.getElementById('main').style.width = newWidth; } } </script> After a bit of playing with it I found that IE seems to return in offsetWidth about 19 more pixels than the actual size of the viewable 'frame', can anyone confirm this? Now, when the browser window is resized I want the width of the element to be resized as well, which meant I had to add to the body tag <body onresize="getBrowserWidth();"> is there a better way to attach the function to when the window is resized? I am not sure how Opera and Safari return offsetWidth and if they do it like mozilla, or need special values like IE does to make it fit. Thanks for all of your help with any of these 'mini' questions This is probably stupid on my part so, I apologize in advance. I created a simple script/function that generates a popup window when you click on a link. The function writes the html code for a media player (the URL for which is passed to the function) depending on what link is clicked, and then creates a text link "Close" below the player. I've put the code below... BUT! Here's what's happening. I tested it on both Firefox and Google Chrome. (I could swear it was working on both once upon a time...but now just isn't...) In Chrome, the player is visible but the close link is not. In Firefox, the player is not visible(but you can find where it's at and pause/resume and etc.) The close link is visible. The audio file plays on both browsers. The window is supposed to have a black background, which is does in Firefox but for some reason it's blue in Chrome? (Minor issue..I know...) Quote: function pop(url) { var generator=window.open('','name','height=200,width=400,status=1'); generator.document.write('<html><head><title>Popup</title>'); generator.document.write('</head><body style="color:white;" bgcolor="#000">'); generator.document.write('<object width="300" height="200"><param name="src" value="' + url + '"><param name="autoplay" value="false"><param name="controller" value="true"><param name="bgcolor" value="#CCCCCC"><embed src="' + url + '" autostart="true" loop="false" width="300" height="200" controller="true" bgcolor="#CCCCCC"></embed></object>'); generator.document.write('<p><a style="color:white;" href="javascript:self.close()">Close</a> the popup.</p>'); generator.document.write('</body></html>'); generator.document.close(); } I can give you the URL for the thing so you can see it in action... http://thetabbfamily.com/cdpages/lifeisgood.php Scroll down 'Purchase Individuals' and click on one of the songs... Hi I am a new bie to Javascript programming. We have a scenario to launch a new browser window for a given HTML. I have the following approaches : Approach 1: my_window = window.open("", "report"); my_window.document.open(); my_window.document.write("<HTML> <BODY> HI </BODY></HTML>"); my_window.document.close(); Approach 2: var newWindow = window.open("", "report"); newWindow.document.body.innerHTML = "<HTML> <BODY> HI </BODY></HTML>"; Could anyone sugges Which is the correct approach ? Our requirement is to have this code to work in any browser? Thanks I have found this Alarm Clock from JavaScript Kit and when the alarm time is reached it redirects to the URL entered. I would like to keep the alarm clock running, have it open a new window for the entered URL such as (Target="Blank") in HTML. Can someone help? var jsalarm={ padfield:function(f){ return (f<10)? "0"+f : f }, showcurrenttime:function(){ var dateobj=new Date() var ct=this.padfield(dateobj.getHours())+":"+this.padfield(dateobj.getMinutes())+":"+this.padfield(dateo bj.getSeconds()) this.ctref.innerHTML=ct this.ctref.setAttribute("title", ct) if (typeof this.hourwake!="undefined"){ //if alarm is set if (this.ctref.title==(this.hourwake+":"+this.minutewake+":"+this.secondwake)){ window.location=document.getElementById("musicloc").value } |