JavaScript - Problems With Printing And Popups Ie9 Ff8
Hello.
Im trying to put in a Popup printer-friendly page on my site. the Popup works great in Chrome and FireFox. It even works in IE - except im getting a black bg instead of the white i get in the other browsers. Also the print command is not working in Firefox or IE. Im running FireFox 8 and IE 9. heres the code for the Popup: Code: <script language="javascript" type="text/javascript"> <!-- function popitup(url) { newwindow=window.open(url,'name','height=200,width=150'); if (window.focus) {newwindow.focus()} return false; } // --> </script> </head> <div> <img src="IMAGES/BidsCouponSmall-text.png" /> <br /> <br /> <a href="printcoupon.htm" target="coupon" onclick="window.open('printcoupon.htm','coupon','height=500, width=400,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no'); return false;" >Click HERE To Print</a> <br /> </div> To avoid cluttering of this post, the page im having printing problems with can be found he http://bidsservice.net/printcoupon.htm its all html, css, and JS. no server-side code. Similar TutorialsI'm trying to display a random message by making an array through values in an XML file and then displaying the info on the page. i want to have it so that a new message is generated each time the button is clicked with no repeats. here is what i have Code: function initial() { var xmlDoc; // First option for internet explorer 5 and 6, second option for firefox, internet explorer 7+ window.ActiveXObject ? xmlDoc = new ActiveXObject("Microsoft.XMLDOM") : xmlDoc = document.implementation.createDocument("","",null); xmlDoc.async = false; xmlDoc.load("quotes.xml"); // take the quote and author information from the xml file var pQuotes = xmlDoc.getElementsByTagName('quote'); var pAuthors = xmlDoc.getElementsByTagName('author'); // create arrays var aQuotes = new Array(); var aAuthors = new Array(); // put the quotes into the array for (i=0; i<pQuotes.length; i++) { aQuotes.push(pQuotes[i].childNodes[0].nodeValue); alert(pQuotes); } // put the authors into the array for (i=0; i<pAuthors.length; i++) { aAuthors.push(nAuthors[i].childNodes[0].nodeValue); } // Loop through arrays and print their quotes and authors for (var s in aQuote) { alert(aQuotes[s]); alert(aAuthors[s]); } } var Q = aQuotes.length; var quoteText = document.getElementById('aQuotes'); var authorText = document.getElementById('aAuthors'); var randomquote = Math.floor(Q * Math.random()); function quoter() { var randomquote2 = randomquote; while (randomquote == randomquote2) { randomquote = Math.floor(Q * Math.random()); } document.getElementById('quoteText').innerHTML = aQuotes[randomquote]; document.getElementById('authorText').innerHTML = " - " +aAuthors[randomquote]; quote.innerhtml = aQuotes[randomquote]; author.innerhtml = aAuthor[randomquote]; } navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false); </script> XML Code: <?xml version="1.0" encoding="utf-8" ?> <quotes> <theQuote> <quote>Over the years your bodies become walking autobiographies, telling friends and strangers alike of the minor and major stresses of your lives.</quote> <author>Marilyn Ferguson</author> </theQuote> <theQuote> <quote>In reality, serendipity accounts for one percent of the blessings we receive in life, work and love. The other 99 percent is due to our efforts.</quote> <author>Peter McWilliams</author> </theQuote> <theQuote> <quote>The secret of joy in work is contained in one word - excellence. To know how to do something well is to enjoy it.</quote> <author>Pearl Buck</author> </theQuote> <theQuote> <quote>The discovery of a new dish does more for human happiness than the discovery of a new star.</quote> <author>Anthelme Brillat-Savarin</author> </theQuote> <theQuote> <quote>When I was born I was so surprised I didn't talk for a year and a half.</quote> <author>Gracie Allen</author> </theQuote> </quotes> HTML Code: <body onload="initial()"> <div id="container"> <div id="header"> <h1>quotes</h1> </div> <div id="content"> <span id="quoteText"></span> <span id="authorText"></span> <br/> <br/> <input type="button" value="Click here for another quote" onclick="quoter()"/> </div> I have 3 pop-ups on a particular page, but when I click any of the 3, they all show up as the same one (the 'form' one, whereas they should be 3 different ones). What do I need to change? Here is the 1st one (triggered by clicking 'Pre-purchase pest inspections'): <SCRIPT language="JavaScript"> function topWindow(){ popup = window.open("timberpest.html","timberpest","width=800,height=850,left=0,top=0,toolbar=no,location=no ,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no"); } </SCRIPT> <li><a onmouseover="window.status='Pre-Purchase Timber Pest Inspections >>';return true;" onmouseout="window.status='';" href="javascript:topWindow()">Pre-purchase pest inspections</a></li> Here is the 2nd one (triggered by clicking the image 'img7.jpg'): <SCRIPT language="JavaScript"> function topWindow(){ popup = window.open("form/form.html","form","width=700,height=1400,left=0,top=0,toolbar=no,location=no,directories=no,status=y es,menubar=no,scrollbars=yes,copyhistory=no,resizable=no"); } </SCRIPT> <td class="bg10"><div align="center"><a onmouseover="window.status='Request Form >>';return true;" onmouseout="window.status='';" href="javascript:topWindow()"><img src="images/img7.jpg" alt="" width="177" height="345" border="0" /></a></div> And here is the 3rd one (triggered by clicking 'Read more...'): <SCRIPT language="JavaScript"> function topWindow(){ popup = window.open("About.html","about","width=778,height=650,left=0,top=0,toolbar=no,location=no,directori es=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no"); } </SCRIPT> <a onmouseover="window.status='About Us >>';return true;" onmouseout="window.status='';" href="javascript:topWindow()">Read more...</a> Hey guys I'll try to do my best to explain what I want. Im using a self hosted wordpress and I want to add and image link in one of my sidebars. Code: Code: <a href="http://www.espn.com" target="_blank"> <img src="ahman.gif"> </a> So When someone click on the image I want a box to appear in same window with all the buttons above(facebook,twitter,Gplus,Digg,StumbleUpon ....(the script for the button is down there )) like that(I want A shadow also) http://oi42.tinypic.com/j0vi1i.jpg After that I want all the bookmarks to be done in this box and not in different window. After the bookmark is done I want to show a thank you message in this box Hope you guys Understood. I dont think is complicated but for me it is The bookmarking script is Here http://newsand-reviews.com/javascript.txt Thank million times for help. If you can help me even with half of this I'll be pretty happy I'm trying to do what they are saying at this link: http://blogs.sitepoint.com/perfect-pop-up/ First, they tell me to do what is listed under the "Scripting Disabled" section: <a href="file.htm" onclick="window.open('file.htm'); <br> return false;" rel="nofollow" target="newWin"> Then, down in the page in the "The Perfect Pop-Up Script" section it has a large script for me to use. I'm wanting to use it at my page http://www.best-stock-trading-system...ng-system.html I want to make each of my images pop up windows like at this site: http://www.polyvore.com/cgi/shop?query=shoes So, are they telling me to use the html in both sections? Where would I put the html in the top section vs. the script in the lower section? Do I have to make another webpage and just paste the script in there and then call it, like they say below: "To call the function you would use the following code:" <a href="my-pop-up-window.htm" <br> onclick="popUp(this.href,'console',400,200);return false;" <br> rel="nofollow" target="_blank">This is my link</a> I'm a bit confused where I am supposed to inserting the page name for the popup that I want to pop up vs inserting the pagename for the script page that I guess I have to make. So what are the steps that I would take to do all of this?! Thank you for your help! I have a tracking ad at the bottom of my site. (no iframes). how do I know and/or prevent that tracking ad from popping up a popup? They are not suppose to, but I suspect they do. Is there a way to track this, or perhaps prevent them from popping the popup from within my page? I have access to various libraries, prototype/jquery etc.. so if there is a func/method in those, I could use too. I have developed one to one chat in asp.net. Now I wanted a gmail chat like feature in it. In left side of page, a list of online users should be available. When I click on a user, a new div should popup on right bottom corner with close and minimise buttons. When I click on another user , a second div should popup on right bottom corner of page but left to the first popup div. I want popping up of divs dynamically. The no of clicked users should decide the no of popped up divs. Also, for each division there should be a separate division ( inside the popped division ) whose innerhtml value is my chat text. And if three divs are popped up and if I close the second one, the third should get attach to first popup. Hope, you'll understand my requirements, and will provide a suitable code in javascript. I found this script while browsing a site: Code: <script language="JavaScript"> <!-- if(popUpsBlocked) alert('Our site uses Pop-Ups.\nPlease enable Pop-Ups for this website.'); } //--> </script> But when I added it to my site, it wont work. Discuss and find a soulution....... I have several 'galleries' for each artist on my website. Clicking on each thumbnail opens a popup window with a larger image and details. It works fine on all the browsers except IE. What do I need to add/subtract/alter so that it works in IE? Tried to find the solution with the other threads, but without success. Here's the website: http://artsenses.co.uk I will be eternally thankful for any help! I'm a complete newbie so please excuse me if this is obvious. I'd like to have a drop down menu that pops up a small new window with an image. So for, every attempt results in the image appearing in a new tab instead of a small, pop up style window. Here's my form <select name="parms"> <option value="AirTemp.jpg">AirTemp</option> <option value="Humidity.jpg">Humidity</option> <option value="Windspeed.jpg">Wind Speed</option> </select> Many thanks. Hi there everyone, My question is one that has been asked many times before always with the same answer. I'm hoping that all the new developments with JQUERY and Prototype that a method would have come about on how to print an external HTML file without first opening it? So you click it and it prints without having to use frames, redirects etc... Any ideas? Quote: var c739=new Array ("C#739","Brick Township","125 Route 65","Brick","NJ","08723","Phone #","1234569"); Quote: var c741=new Array ("C#741","Brick","125 kool st ","copolla","NJ","07831","Phone #","6957891"); Quote: document.write(c739[1]); I need help for the above code. I created a simple Array which would then be growing too soon. I need to add a prompt : store : c739 then all the elements would show as: C#739 Brick Township 125 Route 65 Brick, NJ 07831 Phone# 1234569 Please help. Thank you in advance. Hey. I have been pulling out my hair trying to do this. I am printing out the contents of a DIV tag but it does not print the css with it. Just the basic text For example: .testDiv { border: 1px solid #0F0; margin-right: 300px; text-decoration: underline; font-weight: bold; } The print does not change the text according to the css. Why is this? Thanks in advance for any help. Marc Hi Guys, Using this code i have managed to get the query value from the url. code: PHP Code: <script type="text/javascript"> // Check referrer function getQuerystring(key, default_) { if (default_==null) default_=""; key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regex = new RegExp("[\\?&]"+key+"=([^&#]*)"); var qs = regex.exec(window.location.href); if(qs == null) return default_; else return qs[1]; } var refVal = getQuerystring('r'); </script> <div id="div-regForm"> <div class="form-title">Sign Up</div> <div class="form-sub-title">Earn points & then swap for prizes! FREE!</div> <form id="regForm" action="sign-up.php" method="post"> <table> <tbody> <tr> <td><label for="fname">First Name:</label></td> <td><div class="input-container"><input name="fname" id="fname" type="text" value="<?php print $_POST['fname']; ?>" /></div></td> </tr> <tr> <td><label for="lname">Last Name:</label></td> <td><div class="input-container"><input name="lname" id="lname" type="text" value="<?php print $_POST['lname']; ?>" /></div></td> </tr> <tr> <td><label for="email">Your Email:</label></td> <td><div class="input-container"><input name="email" id="email" type="text" value="<?php print $_POST['email']; ?>" /></div></td> </tr> <tr> <td><label for="pass">Password:</label></td> <td><div class="input-container"><input name="pass1" id="pass1" type="password" value="<?php print $_POST['pass1']; ?>" /></div></td> </tr> <tr> <td><label for="pass">Confirm Password:</label></td> <td><div class="input-container"><input name="pass2" id="pass2" type="password" value="<?php print $_POST['pass2']; ?>" /></div></td> </tr> <tr> <td><label for="cntry">Country:</label></td> <td><div class="input-container"><select name="cntry"><?php foreach($countryArray as $country) { print "<option value=\"$country\">$country</option>"; } ?></select></div></td> </tr> <tr> <td> </td> <td><input name="r" type="hidden" value="<script type="text/javascript">document.write(refVal);</script>" /><input type="submit" class="greenButton" name="submitSignUp" value="Sign Up" /></td> </tr> </tbody> </table> </form> </div> in this part value="<script type="text/javascript">document.write(refVal);</script>" /> i can't seem to put the value in the hidden field it print fine in the code just above. thanks for any help guys Graham I have a routine that prints a textarea: Code: function printInput(f){ var ifr = window.frames['printFrame']; if (ifr){ //print the content of the invisible iframe ifr.document.getElementById('content').innerHTML=f.WRKNOTEPAD.value.replace(/\n/g,'<br />'); ifr.focus(); ifr.print(); } else { //print by opening a new window and then closing it var html='<html><head><style type="text/css">div{font:normal 14px Verdana}</style></head><body onload="window.print();window.close()"><div>'+f.WRKNOTEPAD.value.replace(/\n/g,'<br />');+'</div></body></html>' var win = window.open('','_blank','menubar,scrollbars,resizable'); win.document.open(); win.document.write(html); win.document.close(); } } function writeContent(objIframe){ var html='<html><head><style type="text/css">div{font:normal 14px Verdana}</style></head><body><div id="content"></div></body></html>' objIframe.document.write(html); objIframe.document.close(); } This works nicely when the button is of input type: Code: <form name="FORMNOTES"><textarea name=WRKNOTEPAD cols=140 rows=20 wrap=yes style=\"font-family: Arial; font-size: 10pt\"></textarea><div> <br> <input type="button" value="Print notepad" onClick="printInput(this.form)"> </div> <iframe name="I1" id="printFrame" src="javascript:parent.writeContent(this)" width="1" height="1"></iframe></form> But when I try to make the input button an img button it errors: Code: <img border="0" src="/images/printnotes.gif" onClick="printInput(this.form)"> The error is "WRKNOTEPAD is null or not an object". Is there any way to overcome this and use an image to achieve the same thing? I'm thinking that the image is not an element(?) - is that the reason? Thanks for any light on this. Hi I have the code below which geocodes a postcode and returns a lat a long value. Its standard code from Google maps. I just want to print these values to a screen. I tried document.write(value) but this produces nothing. Any help would be greatly appreciated. Code: <script type="text/javascript"> var localSearch = new GlocalSearch(); function usePointFromPostcode(postcode) { localSearch.setSearchCompleteCallback(null, function() { if (localSearch.results[0]) { var resultLat = localSearch.results[0].lat; var resultLng = localSearch.results[0].lng; } document.write(resultLat+resultLng); //alert("Latitude: " + resultLat + "\nLongitude: " + resultLng + " q"); }); localSearch.execute(postcode + ", UK"); } </script> TIA Stew I have the following code attached that gives me a prime number. I can't seem to put the logic behind having this code print from an alert the prime numbers from 1-100. Of course, this code is only giving me "the" prime number. I just don't know where to begin, or how to store each number. Array maybe?
Code: var finding_primes = function() { var number = 31, prime = true; for ( var i = 2; i < number; i++ ) { if ( number % i == 0 ) prime = false; } if (prime) { alert( number + " is prime."); } else { alert( number + " is not prime."); } } When I use the following script in my web page I do not get a print out. Can anyone tell me what is wrong? <!-- Begin // Get today's current date. var now = new Date(); // Array list of days. var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); // Array list of months. var months = new Array('January','February','March','April','May','June','July','August','September','October','Novem ber','December'); // Calculate the number of the current day in the week. var date = ((now.getDate()<10) ? "0" : "")+ now.getDate(); // Calculate four digit year. function fourdigits(number) { return (number < 1000) ? number + 1900 : number; } // Join it all together today = days[now.getDay()] + ", " + months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear())) ; // Print out the data. document.write(today); // End --> 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 I'm newbie to javascript. I'm trying to print a web part in landscape orientation. I want to include CSS in java script and change the layout of the page. Here is the print code Code: function printWebPart(tagid) { if (tagid) { var html = "<HTML>\n<head>\n"+ $("HEAD").html()+ "\n</head>\n<body >\n"+ $("#"+tagid).html()+ "\n</BODY>\n</HTML>"; var printWP = window.open("","printWebPart"); printWP.document.open(); printWP.document.write(html); printWP.document.close(); printWP.print(); printWP.close(); } } </script> and here is the css class : .landScape { width: 100%; height: 100%; margin: 0% 0% 0% 0%; filter: progid:DXImageTransform.Microsoft.BasicImage(Rotation=3); } Please suggest how do i do this? I'm trying to get this code to work in browsers other than IE. It prints the contents of a textarea, say, a notepad, first bringing up the print dialog. It does it with an (almost) invisible iframe. At first I thought it was only for IE, but I must have tested incorrectly (after a few dozen times uploading and printing out you lose your sanity) and I now see that it DOES work in FF, but not in Chrome. For me (and maybe others?) that is very good news because it will probably be easier for someone more knowledgeable than me to solve a Chrome problem rather than an "all other than IE" browsers problem. Code: /* for notepad printouts */ function printInput(f){ var ifr = window.frames['printFrame']; if (ifr){ //print the content of the invisible iframe ifr.document.getElementById('content').innerHTML=f.WRKNOTEPAD.value.replace(/\n/g,'<br />'); ifr.focus(); ifr.print(); } else { //print by opening a new window and then closing it var html='<html><head><style type="text/css">div{font:normal 14px Verdana}</style></head><body onload="window.print();window.close()"><div>'+f.WRKNOTEPAD.value.replace(/\n/g,'<br />');+'</div></body></html>' var win = window.open('','_blank','menubar,scrollbars,resizable'); win.document.open(); win.document.write(html); win.document.close(); } } function writeContent(objIframe){ var html='<html><head><style type="text/css">div{font:normal 14px Verdana}</style></head><body><div id="content"></div></body></html>' objIframe.document.write(html); objIframe.document.close(); } I think this bit: if (ifr) tests for IE and if it fails the condition, it dynamically creates a new window to print from. And I now see it does just this in FF. But not in Chrome. So narrowing it down I think the Chrome failure is in this bit: Code: else { //print by opening a new window and then closing it var html='<html><head><style type="text/css">div{font:normal 14px Verdana}</style></head><body onload="window.print();window.close()"><div>'+f.WRKNOTEPAD.value.replace(/\n/g,'<br />');+'</div></body></html>' var win = window.open('','_blank','menubar,scrollbars,resizable'); win.document.open(); win.document.write(html); win.document.close(); } Is there anyone who can see why this would fall over in Chrome? |