Javascript + CSS Switcher For Printer Friendly Webpage
Sep 11, 2007
I am developing a site for a client that requires the printer friendly verison of the site to appear in a separate pop-up window. I am having trouble figuring out the scripting needed to have the current page open in a separate window with a different style sheet applied to it.
I have a print button in PHP page which using javascript window.print() to print web page.
However , when user click "print" , the print preview display that the page cut-off and alignment is out.
Read on regarding the matter , and found that is not the issue of PHP . Some users recommend to me to use CSS and HTML to create printer friendly page. However my page is extension is in php , can i use CSS and HTML to create printer friendly page?
In practice you can't. While you could create a suitable encryption system with a password in the page, the level of support you need to do this means it's always simpler to do it server-side. Anything that "protects" a page other than the current one is definitely flawed.
Here 'some_function' is opening the 'pagename' in a new customised window.
This page also contains a few images weighing 50kb. Now if I click the <a> links before the images are loaded fully, following happens (on my pc it works well but it happens when i test it online):-
1. The new page opens in a window as required 2. But the page loading is ABORTED and the images are not loaded.
I work for a small college and we were recently given permission to use a particular GPA calculator on their website. They sent us a javascript file, that I now have. I am trying to incorporate this into our website, but I don't really know much about javascript and I am having trouble making it work.
You can view the GPA calculator here to help clarify what I mean... If someone could just help point me in the right direction or if anyone know a site with tips that would be helpful to me..
I want to let users to print an automatic generated image from a web page. the problem is that the image is big (little smaller than A4) and if I print the page from "File --> Print" the image is automatically resized or printed in more than one page, if I set the page properties from the File menu I can reduce print margin and cut off header and footer, and then it works fine. So I would like to set page properties form javascript to let users print the image with right dimensions.
The coloumns of the tables in my jsp page have links on them for sorting. The same table is displayed in the printer freindly version but i want to disable these sorting links on that printer freindly page.
I wonder if some one could help me with an issue that I have with an image switcher.
I have 12 Images with a discription to each one. Now, the script is working, as it is now, but the background on the page is black and I am trying to change the font color to white (#FFFFFF).
I believe I have tried it all, and I can get the font color to be white on the working page (FrontPage), but I just can't get the white font to shine up in the preview browser.
Why I know that it is working? Well, I marked the text below the image in the preview browser and as I hover over the links, the marked text is actually changing synchron with the 12 images. Code:
many framed sites have an ancient script in all their pages: if(top==self) top.location=theframeset
Some friendlier ones do this: if(top==self) document.write( '<a href=frameset>This page is ' + 'supposed to be frames</a>.' )
These scripts fail when the page is loaded within somebody's else's frameset.
Then top is not self but not a very cooperative top either. And with ever growing security issues browsers have become quite paranoid. Even testing for top's origin results in an error:
alert(top) // gives me [object] var s='' for (var i in top) s+=i+' '+top[i]+' ' alert(s); var obj; try{ obj=top.location; } catch(e) { obj='' } // give me [access denied] (of course)
I 'd rather drop the frames altogether, but the site has been like this for years and the client insists. There are frames. So how would I detect when it is appropriate to write:
<a href=>View this page in its <b>own</b> frames.</a> ?
Question b: in the frameset, a little script looks into self.location.search for an url with which to fill the main frame. Is there a way to avoid document.write and onload?
When the user clicks on the password form field, the background image is suppossed to be replaced with a white background color. All I get is a javascript error, and I copied straight out of the newsletter.
I have an html based website that needs urls converted from [URL] to [URL] the website has no mysql database. the urls are written through javascript. download from below the js + html files Code: [URL] urls writing rules can be found on common.js and set_form_menu.js.gz files
I spent a lot of time finding code that would play an audio (.wav) file on a mouseover cue that would work in Internet Explorer 6 and FireFox without any user prompt to allow active-x scripts to be run etc, but unfortunately the code does not work in Internet Explorer 7. Can you suggest an alternative?
PROBLEM 2:
When using a image switching code to swap an image to a .gif anim that plays just once (created using Ulead Gif Animator 5), Internet Explorer 6 and FireFox begin the animation cycle only when the image has been switched. Unfortunately, Internet Explorer 7 seems to play the animation as soon as it has been loaded so when it’s switched you only see the last frame. Can you suggest an alternative? Code:
I need to take text from a database, turn it into a barcode from the Web and print to a Zebra Z4M barcode printer. I am stuck at two separate approaches.
1. Use ZPL II (Zebra's proprietary language to command the printer) which is executed at a DOS Prompt with "COPY BarCode.txt LPT1" Is there any way to run that from the web. Also, is there any other method of sending the information in the text file to the printer?
2. Use some sort of ActiveX object to compile a barcode label image, then use another ActiveX object to remove the Header/Footer and Margins from the IE printout. I have found ActiveX objects that can compile the image, but have not found anything to block out the Header/Footer and Margins.
I have one image (sampleImage.png).. Already i connected my pc to printer....Manually i open the image and select print option , then i got image from printer....Now i want print image using javascript....
so my professor suddenly took a left turn in class and we jumped from using HTML and CSS to programing in Javascript. It's not even covered in the book we're using for a text book. So I'm having some problems with it (big surprise right?) My assignment: Write a Java Script that will print out the Temperature in Celcius from 0 to 35, AND the corrosponding temperature in Fahrenheit. So basically it would generate the following:
0 Degrees in Celcius is Equivalent to 5 Degrees Fahrenheit 1 Degrees in Celcius is Equivalent to 6.125 Degrees Fahrenheit 2 Degrees in Celcius is Equivalent to 7.25 Degrees Fahrenheit 3 Degrees in Celcius is Equivalent to 8.375 Degrees Fahrenheit and all the way down to 35 degrees.
Is it possible to do something like this: On a site there is a link that says "Darken Page".Upon clicking the link, the background color turns black.The link then changes to "Brighten things up"So just a style sheet switcher, but with one link and changes
I've been applying a javascript based, user switch button to a site from this article: [URL] On [URL] (right top menu option).So far, it is working but the user selection is not persistent from page to page. I think it may have something to do with the onload and unload actions in the attached js file: [URL]
} window.onload = function(e) { var cookie = readCookie("style");
[code]....
I was wondering if these functions have to be in the header of every page instead of in a linked file, or if there is something else I'm missing...
I'm battling to print labels on a dot matrix printer. The available page sizes are all bigger than a single label and I can't make custom page sizes on this printer (panasonic KX-P1150). Whenever I print a label, the printer form feeds the label paper and does not stop after the label. I have googled and see that printer comands can be send directly to the printer with ActiveX controls from inside a javascript but the only examples I found changed the orientation etc. None changed the page size or disabled the form feed.
So. I've been working on this stylesheet switcher for a school project, and basicly there are 3 layouts, "Standaard", "Zwart-wit" and "Printversie". What I want is that when you select one on (for example) the homepage, I want the other pages to apply the same stylesheet. I've been trying to do that with cookies, but it doesn't even work on one page.
PHP Code: function setup() { var current_style = read_cookie();
Looking over other threads on this site I was able to use another members script to build my own for adding a network printer via JavaScript on our Intranet. With that, the script works perfectly fine when testing it on the local machine I built it on, but not on other machines in the office. Currently I'm remoted into the branch office I reside in from the corporate office where I'm currently at so the machines being tested are on different subnets, but the script is simple calling the UNC path for the printer. When tested on any other computer, and the link is clicked on the page, the user is taken back to the folder in windows explorer the HTML file is saved in, rather than executing the add printer portion of the script.
This is my full code as of now, I was trying to get the function correct before formatting the actual website (obviously) Code: <html><head> <meta http-equiv="Content-Language" content="en-gb"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Printer Mapping</title> </head> <script> function addPrinter25(){ var x=confirm("You are about to add printer GPSACC01. Would you like to make this your default printer?") if (x==true){ WshNetwork = new ActiveXObject("WScript.Network"); var PrinterPath = "\\gpsprnt02\gpsacc01"; WshNetwork.AddWindowsPrinterConnection(PrinterPath); WshNetwork.SetDefaultPrinter(PrinterPath); alert("Printer GPSACC01 has been added successfully and set as default") }else{ WshNetwork = new ActiveXObject("WScript.Network"); var PrinterPath = "\\gpsprnt02\gpsacc01"; WshNetwork.AddWindowsPrinterConnection(PrinterPath); alert("Printer GPSACC01 has been added successfully") }} </script> <font color="#0000FF" face="Arial"> <a href="" onclick="addPrinter25(); return false;">GPSACC01</a></font> </body></html>
I have this style switcher which is awesome, therefore, the cookie does not seem to work, actually it simply doesn't.
<script type="text/javascript"> // *** TO BE CUSTOMISED *** var style_cookie_name = "style" ; var style_cookie_duration = 30 ; // *** END OF CUSTOMISABLE SECTION *** function switch_style ( css_title ){ // You may use this script on your site free of charge provided you do not remote this notice or the URL below. Script from [URL] .....