My Next New Web Site
I put together a new web site dedicated to my viola career. It hosts my profile, repertoire, and contact information. Soon I will start a media gallery with photos and personal recordings.
Comments are welcome.
I put together a new web site dedicated to my viola career. It hosts my profile, repertoire, and contact information. Soon I will start a media gallery with photos and personal recordings.
Comments are welcome.
Out on my deck, I had this spider that wove a web that must have been 2 feet in diameter. My first instinct was to tear down the web and squash the little bugger. But I had some crisis of Buddhist-like conscience when I thought about how long it took to create the web. Every night like clockwork, this spider weaves this web to catch its dinner. And every morning it tears it down to start all over again. It made me think about how humans get up every day and go to work to proverbially catch their own dinner. Sympathy for the spider?
Here are some pictures of its artwork:
I mean, I understand we need spiders to control the insect population. But why in my “backyard”? Go climb up someone else’s deck. I did become comfortable with the little guy, as long as I kept my distance. Could this be a metaphor for my ability to coexist with those that I find strange and threatening? I mean, it’s not like this itty bitty spider is a real threat to me. I’m more of a threat to it.
Eventually, the rain came and washed the spider down the spout. It did make a come-back one night. But since then, I haven’t seen my new friend. I will miss him.
I had an occassion where I had to capture the “enter” key press in a text box and couldn’t quite remember how to do that. So, like the well-adjusted web developer I am, I Google’d for the answer. I was suprised to find how many different solutions there were and how some of them just plain didn’t work.
I turned to the tried-and-true Prototype library (because that’s how I remembered doing it in the first place). The bonus with using Prototype is that it will actually be browser compatible.
Here is the penultimate solution to capturing an “enter” keypress in an HTML input text box.
The HTML:
<input type="text" name="my_text" id="my_text" value="" />
The JavaScript:
<script type="text/javascript"><!--
function onMyTextKeypress(event)
{
if (Event.KEY_RETURN == event.keyCode) {
// do something usefull
alert('Enter key was pressed.');
}
return;
}
Event.observe('my_text', 'keypress', onMyTextKeypress);
//-->
</script>
Now, don’t forget to include the prototype.js script in the HTML page!
<script type="text/javascript" src="/js/prototype.js"></script>
The JavaScript must execute after the DOM elements are rendered. One way to do it is to put the JavaScript code in a SCRIPT element after the INPUT element. However, another way would be to put the following code in the SCRIPT element in the HEAD element:
Event.observe(window, 'load', function() {
Event.observe(Event.observe('my_text', 'keypress', onMyTextKeypress);
});
I like this method because all the JavaScript can be kept in the HEAD, or in a JS library file, instead of splattering the code throughout the document body.
Try it:
References: