Monday, November 12, 2012

Hiding elements from printing

The question comes up all the time: Can I prevent people from printing my web page or an image on the page?  The short answer is unfortunately "No".  You can make it difficult for them, but a determined visitor will still find ways.  So far nothing I'm aware of can prevent them altogether.  Basically, if you put it on the page, they can see it and find a way to print it.

Another way of looking at the same problem is removing elements of your page that don't need to be printed.  For instance, if somebody is reading an article on your site and wants to print it, they probably don't need the navigation, advertisements or a print button on the printed page.  They want to read the article, not look at the framework around it.

Wednesday, November 7, 2012

Doctypes: What are they and why should you care?


Imagine walking into a room where everyone speaks english, but they all come from different countries, and different sections of each country.  It's all the same language, but the words they use can mean different things to each person.  For instance, somebody from England might ask you to "fetch a torch from the boot".  To an American, that wouldn't make much sense unless you knew to expect the British version of English.  Then you'd know that he was asking you to get a flashlight from the trunk of his car.

A doctype can be thought of as a definition of what variation of language your page is written in.  If you don't specify a doctype, each browser will try to interpret things their own way and the results can either be subtly different or completely off, so a doctype should be considered mandatory.  Unfortunately, they are very often forgotten about until after you've spent hours or even days trying to figure out why your page isn't working as it should.

Thursday, November 1, 2012

jsFiddle - A site for debugging

Sometimes you just need an environment where you can put together your HTML, CSS and javascript without having to build a server, install different javascript libraries, build your page and all that... you just want to see how this fragment of code would work.  Or you need to show another developer how a certain bit of jQuery or CSS works and you don't have a site they can access.  Maybe you can't get it working, and want to ask your favorite support forum for help?  There are many sites out there which can help, including one that I use for many of my posts here on jUntangled as well as when I'm helping other members of Experts-Exchange with questions they have.  I heard good things about jsFiddle for this purpose, and signed up for a free account there.  Here's what I found...