So you thought that you knew everything there was to good old javascript did you? Well then, check out the slayeroffice web site first and then ask yourself again whether or not you are such a big shot afterall.
Personally, I found the Mouseover DOM Inspector the most impressive of all.
Don't you just hate it when you include some external piece of (javascript) code from another site, and it breaks up the layout of your web page?
This is the problem I've been having with Blogsob. The kind folks there provide a free service for members of the blogging community, enabling you to increase your blog's exposure via simple text-based ads.
All you have to do is insert the following code somewhere and hope everything works out okay:
<script src="https://www.blogsnob.idya.net/ad.php?id=n" type="text/javascript"></script>
I have placed this at the very bottom of my right-hand margin. This margin is set to a width of around 160 pixels and it is meant to stay that way.
The only problem with inserting this piece of code is that you do not know ahead of time how much text and/or images might be thrown into your site. Now I trust the service for what it is, and most of the time it seems to be working alright. However, sometimes I get really long words containing say 50 characters in a row. This breaks up my layout. In order to accommodate this exceptionally long word, the poor 160 pixel wide margin is expanded so that a much larger vertical bar appears. You see, HTML has no character wrapping, only word wrapping at the white-space borders. My main content area is covered up on the right side and shifted to the left. Bummer, man.
So what's a poor soul like myself going to do? Well, I have chosen to solve this using good old Javascript based on the DOM-interface. Here is what I do. First of all, I bracket the inserted code above like this:
<div id="blogsnob"> <script src="https://www.blogsnob.idya.net/ad.php?id=n" type="text/javascript"></script> </div>
Note that I have wrapped the ill-behaved section of code with another div-tag and I have labeled it "blogsnob" accordingly.
Then just right after the spot where I have inserted the code above, I add the following function call:
<script language="javascript" type="text/javascript"> <!-- mxw("blogsnob"); //--> </script>
Alright, so what does this magical function called mxw()
really do? Well, it looks within the div-tag that I labeled as "blogsnob", recursively parses through the nodes and child-nodes, and grabs each TEXT-element. If it then finds any words which are longer than a pre-defined maximum length, say 20 characters (mxw_max = 20;
), then it will truncate this bugger to this given length. Pretty neat, huh?
Just in case you were curious what this function looks like, and assuming that you not only have a good knowledge of Javascript, but also at least some limited experience with that thing called DOM, then here it is:
<script language="javascript" type="text/javascript"> <!-- // Maximum allowed length of text words. var mxw_max = 20; // // mxw(id) // // Wrapper function which checks that certain DOM // is supported before calling recursive mxw2(). // function mxw(id) {  if; (!document.getElementById) return;  var; n = document.getElementById(id);  if; (!n || !n.nodeType) return;  mxw2;(n); } // // mxw2(id) // // Checks all text of given node and all its // descendant nodes, truncating each word that // is longer than allowed length mxw_max. This // is an extra safety valve preventing unwanted // overrun, e.g. of sidebars and/or margins. function mxw2(n) {  if; (n.nodeType == 3 /*Node.TEXT_NODE*/) { var flag = 0; var words = n.data.split(" "); for (var i = 0; i < words.length; i++) { if (words[i].length > mxw_max) { flag++; words[i] = words[i].substr(0, mxw_max-2) + ". "; } } if (flag > 0) n.data = words.join(" "); }  var; children = n.childNodes;  for; (var i = 0; i < children.length; i++) mxw2(children[i]); } //--> </script>
Hope you like it and find it useful for your own web pages somewhere. You're welcome.
Here's some more javascript stuff which you too can use in order to achieve yet another truly amazing affect. Boggle the minds of your readers and make new friends. Just click on the following button to find out for yourself:
Alright, so I get kind of bored once in awhile, so what? Everyone has those periods when all you feel like doing is doing nothing at all. Nothing at all like a good old bout with some amazing Javascript, that is.
Here is something I created this morning, something quite silly but still entertaining nonetheless. And to think that I did it all with some simple Javascript. Try it out please.
Kind of reminds me of that program called Life, remember it? A simulation of living objects based on the population, available food and number of neighbors and other predators. I guess I could enhance this simple creation to include some kind of intelligence, but that will have to wait until another day (sorry).
If worse comes to worse, I can always find a job somewhere as a Javascript programmer. Want to hire me?
Hope this made your day. It did mine.
Alright, so I finally have gotten so overly fed up with those droves of spam emails the flood my in-box everyday that it is time to do something about them. After having read the article Spam-Proofing Your Website, I have taken some of their suggestions at heart and have begun to cloak all email addresses displayed on my homepage and blog. You see, there are millions of so-called spam harvesters crawling all over the Internet, consuming page after page and extracting all the discovered emails. To be used for junk email, those jerks. I am curious if I will now be getting less junk email (about 60 per day and growing).
<script language="javascript" type="text/javascript">
<!--
// Try and spoof those nasty spambots!
document.write('<a href="' + 'ma' + 'ilto:k');
document.write('iffin' + '@' + 'cyber-gi');
document.write('sh.com' + '">' + 'kiffin (at) ');
document.write('cyber-gish' + '</a>');
//-->
</script>
And this is what all that mumbo-jumbo code (hopefully) looks like after it has been parsed by your internet browser and presented in readable form: [ ]
Now be honest. If you were a spam-bot, would you be able to figure out what this is? I've heard that they are getting pretty smart lately, even able to scan Javascript code and understanding it, but I doubt very much if this can ever be understood.
Here is an email encoder site which you might find useful, or you can also try out this anti-spam obfuscator.
Since my birthday is coming up soon, I decided to order two more books from Amazon in the hopes that my shipment will arrive in time for the big event. They've got less than nine days, but so far I have never had to wait more than a week. Now I will tell you which two books I ordered if you promise not to make fun of me. The titles are:
Right now I am reading a bunch of books simultaneously in my never-ending attempt to acquire infinite knowledge. Nine books all in a row, to be more precise. Depending on my mood at a given instant, I will jump from the one book to the other. Sometimes smack dab in the middle of a chapter, I will close the book I am currently reading and open up another book. Some reading sessions consist of switching books five or six times an hour. I suffer from an insecure feeling that perhaps I am not increasing my knowledge as productively as I should. That what I am reading at the moment is not valuable enough in the sense that I am suffering an acute shortage by not improving my life sufficiently and quickly enough! This can be very frustrating. The innocent pleasures of reading suffer in that regard which is ironic to say the least. There is this endless source of interesting information out there, and there is absolutely no way I can absorb it all in the limited span of my lifetime. By nature I have an addictive tendency, a proclivity which bends me in fixations. Especially when it is in any way remotely related to the esoteric acquisition of knowledge. So why bother in the first place? Infinite knowledge is preferable, of course. Unfortunately one cannot attain this by reading, even if one could have enough time to read every single book in every possible language that has ever been written in the history of civilization. In order to give my readers a hint of how far along this reading adventure I have come, here is a list of books that currently lie on the reading table next to my bedside. The order is from bottom to top, or since I am by nature symetrical and neat, from the widest (usually the thickest, but now always) in decreasing order:
When I arrived home I was so very excited to receive my latest order from amazon.co.uk that my heart started beating wildly. I ripped open the box and let out a gleeful shout. The reason:
Javascript, The Definitive Guide by David Flanagan.
Yes, yes, yes. As if there is still even more to learn. Haven't I learned enough? This weekend I plan to saw through the exciting thickness and learn as much as I can about javascript this wonderful programming language for the web.
At heart I guess I remain quite an Internet geek.
Email: | |
MSN: | ![]() |
ICQ: | 101918614 |
AIM: | ![]() |