Results 1 to 3 of 3

Thread: Create text only CSS (like print friendly but text displayed on browser)

  1. #1
    Join Date
    Oct 2007

    Create text only CSS (like print friendly but text displayed on browser)


    I need to find a way to create a 'click here for text only' version of my webpage(s) and I'm assuming I can do this in a similar way to 'print friendly' stylesheets... so that when the 'text only' link is clicked the same page is displayed on either the same or a fresh browser window, but using a text only stylesheet - to remove all the unnecessary elements of the page.

    Does anyone know a way to this? I've done it for print - but this automatically selects the stylesheet based on the media (so click on print and the browser applys the print.css styesheet).

    Cheers for any help

  2. #2
    Join Date
    Apr 2003
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Dec 2005
    Try using javascript to switch the media type of the stylesheets:

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
      <title>Your Site</title>
      <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
      <meta http-equiv="Content-Language" content="en-us" />
       <link rel="stylesheet" type="text/css" media="screen" href="web.css" />
       <link rel="stylesheet" type="text/css" media="print" href="text.css" />
    <script type="text/javascript">
    /* <![CDATA[ */
     function textOnly() {
      for(i=0;i<document.styleSheets.length;i++) {
       if(document.styleSheets[i].media == "screen") {
        document.styleSheets[i].media = "print";
       } else {
        document.styleSheets[i].media = "screen";
    /* ]]> */
       <a href="#" onclick="textOnly();">Toggle Text Only</a>
    Last edited by aj_nsc; 03-27-2008 at 10:12 AM.
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center