Now This Log

« 19 February 2002 « - Back Archives Next - » 18 March 2002 »

day permlink Wednesday, 20 February 2002

permlink Hiatus

Hiatus: Time for heads-down mode on things other than a weblog.

Back in a few weeks. permlink  

permlink OS X again

MacOS X 10.1.3 is out. I'm going to wait to update until I do another backup and have at least a small period of downtime.

MacinTouch and MacFixit have reader reports of various problems (mostly for people who mess with their system in ways I don't) but also news of improvements and snappier performance. I can hope... permlink  

permlink Is Javascript On or Off?

Turns out there's a more straightforward way to do what I wanted, with no need for style sheets or putting scripts in the <head> or ...
<script language="JavaScript" type="text/javascript"><!--
    document.writeln('JavaScript is ON');
// --></script>
<noscript>JavaScript is OFF</noscript>
(thanks to Matt W.)

(Follow the comment link to read about the overly-complicated stylesheet-manipulating JavaScript I threw together the other day to do the same thing in a worse way...)

I made a low-tech but useful JavaScript for myself the other day. On the page my browser opens to first, I wanted a way to immediately see if JavaScript is on without going into IE's (or Opera's) menus or preferences to check. I know of no browser (except possibly some branch of Mozilla I haven't seen) which has a status indicator specifically for that piece of information. So I made one.

One caveat -- it only works if you have style sheets enabled. (But it seems most folks do.)

The result looks like this: [disabled because I kept getting some weird errors from it]
JavaScript is  ON  OFF
(Turn on or off JavaScript and reload to see the difference.)

So far I've seen it work in IE6/Windows, Opera 6/Windows, Mozilla 6/Mac and IE 5.1/MacOSX, so there's a decent chance it'll work in plenty of other browsers. 'Working' is defined as showing the red 'ON' when you load the page with JavaScript turned on.

Anyone not interested in the code can stop reading now...

This goes between your page's <head> tags (or put just the function in an external script, like I did for this very page):
<script language="JavaScript" type="text/javascript"><!--
function jstest() {
    document.getElementById('jon').style['background'] = 'red';
    document.getElementById('joff').style['background'] = 'white';
}
//--></script>
In your opening <body> tag, add an 'onload' entry like so:
<body onload="jstest()" bgcolor="white" text="black" [etc...]>
Then somewhere in your main page body, put something like this:
<small>JavaScript is <b><span id="jon" style="color: white; background: white;">&nbsp;ON </span><span id="joff" style="color: white; background: green;">&nbsp;OFF </span></b></small>
You can change the code to display what you like; it's all text and colors, no graphics. Just keep track of the names of your id tags in the <span>s, making sure they match the values in the script. Also, make sure that the colors for 'invisible' pieces match the background of the page (in this case, white). You can obviously play with these values (maybe you want OFF to be red and ON to be green...). permlink     3 comment(s)  
The following works without CSS support (ie: even earlier browsers). Just stick it in the body of the document... JavaScript is OFF Throw in tags in the writeln/noscript sections if you want it to look prettier. Re: the mozilla note... with any mozilla, head over to http://xulplanet.com/downloads/view.cgi?category=applications&view=prefbar to get a toolbar that shows and lets you control your javascript enabled/disabled setting (and a couple others). Bummer is that when you upgrade Mozilla, you have to go back to xulplanet to re-install the toolbar.
      ...posted by matt on February 20, 2002 1:43 PM
OK, so it was pretty much just an exercise for which there was a better solution sitting out there. Still, I learned stuff doing it.
      ...posted by Steve on February 20, 2002 1:46 PM
...and I learned something from your having done it too. I've yet to fiddle with any of that DOM stuff. Looks like you can do some neat stuff with it. :)
      ...posted by matt on February 21, 2002 4:31 PM
Add a comment...

« 19 February 2002 « - Back Next - » 18 March 2002 »

Home - Log - NowThis Consulting - Writing - Media - Links - About
© MCMXCVII-MMVI Steve Bogart