htmlgoodies.com - Home

By Joe Burns

Use these to jump around or read it all...

[Here's What's Happening [Other Uses]

The best tutorials come from readers either asking how they can get a specific effect, or readers sending me a command and asking what in the world it does. It just goes to show that people do look at each other's source code.

The other day I received a submission from John Miller at Dynamic Drive who asked if I had seen a certain command in action. I had seen the tag he was discussion, but never paid much attention to it because it didn't really do anything that I thought was all that great. In addition, the attributes attached to the LINK tag don't really work. Only three attributes are currently set up to function.

Ah but yet, John to the rescue. You should know right up front that at the time of this writing, this command is only supported by Internet Explorer 4.0 and above. I don't know that it can quite be referred to as DHTML because the effect isn't that dynamic.

So, if you are running an IE4.0 or better browser, follow this link and do what the page tells you.

waiting...waiting...waiting

Oh, good. You're back. How did you like that, huh? I get letters all the time asking how you can stop someone from printing a page. Well, you can't. Even by using this format I'm about to tell you about, you really can't. All I would need to do is copy and paste the page and print that, but tricks aside, I basically forbid you to print the page.


Here's What's Happening

Actually, I didn't forbid you at all. The page that printed was what's known as an alternative page. I set up a command in the HEAD tags that stepped in and redirected the print command that you sent to the browser. Basically, I set up a route that lead the browser away from the page you were currently looking at. Here's the code that did it:

<link rel=alternate media=print href="printversion.txt">

Just that. Here's what's happening:

So what actually happened?

I set up the command so that it would step in and redirect the browser's print function to print another page. In this case, you printed "printversion.txt". That page said that you didn't have permission to print the page.

Pretty tricky, eh? You actually did print something, but the effect was that you were denied the ability to print. Please, note that you can print other formats. When John sent me the command he had it set to print a WORD document. As long as the user's computer has the ability to read the page, it can be printed. I just went with a text page because I know that all computers, no matter what their level of advancement, can print text.


Other Uses

Outside of giving the impression that I stopped your ability to print, I see this being very helpful with forms or charts or just about any other support document required for a site. For example, maybe you have a page that requires a user to fill out a form. You could use this tag to make it so that all one needed to do was hit the print button and the form prints out. If you have a chart in XLS format, you could do the same.

I would use an internal browser test JavaScript to test the person's browser when using the command. You could set up the internal test so that if the user is running IE4 or better that text would be written that reads, "To get the form, simply click your print button". If the browser is different, then set the JavaScript to write a hypertext link so that user can go to a page and print the form.

I wish this command were more widely available because I see a great many uses for it. In fact, I intend to set up just such a format in one of my online classes. It would be a great way to distribute homework to students.

And students just love that homework, let me tell you.

 

Enjoy!

 

[Here's What's Happening]
[Other Uses]

 

Back To The HTML Goodies Home Page


Make a Comment

Loading Comments...

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
  •  
  •  
  •  
Thanks for your registration, follow us on our social networks to keep up-to-date