www.netsi.dk

"The internet is just a layer on the real world" (don't forget that!)

Printing HTML pages, make screen and print appear the same.

When using external stylesheets on a webpage you can specify which “media” it should apply to. For instance see these lines:

<link rel="" href="Blueprint/screen." type="text/css" media="screen, projection" />
<link rel="stylesheet" href="Blueprint/.css" type="text/css" media="print" />

As you might allready have guessed the screen.css will be choosen for screen (read: browser) and projection mode. When printing the print.css will be choosen if you print the webpage. So far so good.

Some times you will have a specific page for print, which say will render only a stripped down version of your content and prompt the user with a print dialogue (using a javascript window.print() line of code). But when you see the page in the browser you are in “screen” media, and the style shown will be as defined in the screen.css. You may confuse the user as he gets a screen version ready for print – and printing it wil result in a version based on the print.css. I have made a jQuery based fix for this situation.

The page before and after the fix

The jQuery fix

The fix will disable any external stylesheets related to screen and make the print.css work on media types “all”. It is coded so that it will check for a “#print” added to the URL. So you should simply make the URL of the printversion have a “#print” in it. Here is the fix:

   1:  <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.6.2.min.js"></script>
   2:  <script type="text/javascript">
   3:  /* STH: 2011-07-07 Make any stylesheets target for "print" media active on "all" media types (including screen)
   4:      Also disable any layouts for screen
   5:  */
   6:  jQuery(function() {
   7:    var bPrint = (window.location.toString().indexOf('#print')!=-1);  
   8:    if (bPrint) {
   9:      // The user wants to print this page
  10:      jQuery('link[media*="print"]').attr('media', 'all'); // Enable the print styling for all media types, including screen.
  11:      jQuery('link[media*="screen"]').remove(); // remove any styling related to screen
  12:    }
  13:  })
  14:  </script>

 

The fix above has a link to jQuery, you do not have to include it if you allready have jQuery on your webpage.

Share

How to disable Skype callto in Chrome

offers a service where it will replace links looking like phonenumbers in any webpage you visit with a “callto” link. That link will then let you click on the phone number and do a call to the linked phonenumber. It can be a very nice feature, but sometimes you don’t want that service. Here is how you disable that feature:

This is how it looks like when Skype have inserted a “callto” link in :

Skype tries to add value to webpages by adding links to open Skype on phonnumber-alike text on webpages

  • Open “chrome://extensions/
  • Locate the “Skype Extention”
    On the Chrome "extentions" page you can quickly enable/disable extentions - including the Skype callto extention
  • Click the “Deactivate” (above screenshoot is in Danish, it reads “Deaktiver”

The disabling will be disabled as you click (no restart of browser). Here is how the above webpart looks like:

The original webpage with a phone number, unchanged by Skype

Disabling Skype callto in other browsers
Share

Dynamicweb eCommerce: How to redirect to basket after user have added something to the basket

When using the system in CMS you can add a param to the form which will then send the user to the basket after he/she have added an item to the basket. That is sometimes a logical step for some types. The soloution is simpel, just add a param called redirect as a hidden input field like this:

<input type="hidden" name="redirect" id="redirect" value="/default.aspx?id=156" />

In this example Dynamicweb will send the user to the page with the ID 156 when the form is submitted.

Share