by Mashhoor Al Dubayan
I’ve recently made a small script that you could use to automatically generate a drop-down navigation from an existing list-based navigation on your web page. The script will detect the navigation with the ID you provide, generate a drop-down equivalent and insert it within an element you specify. Choosing any option of the drop-down list would send you to its corresponding link (as seen on many sites).
Read the rest of this entry »
by Mashhoor Al Dubayan
That’s one thing I’ve always wanted to do in JavaScript - calling a script from within another script, like the @import command in CSS or include in PHP/C/C++. JavaScript doesn’t support this natively. I thought there’s no workaround until today my friend, Egor Kouchnarev, who is web designer, asked me whether it’s possible to do this using document.write to write some <script /> tags/links in a document’s head. It was a pretty good idea, except It’s better implemented by manipulating the DOM.
Read the rest of this entry »
by Mashhoor Al Dubayan
If there’s one thing that frustrated me so much in JavaScript, it would be dealing with events (thanks to Internet Explorer). Most of the scripts handling events out there contain lots of browser and/or feature sniffing to decide which event method to use. For example, the following is a code excerpt from Sitepoints DHTML Utopia (the worst books I’ve read on the topic by the way):
if(window.event) // IE check
el = window.event.srcElement;
if(e && e.target) // standard-compliant browsers
el = e.target;
This seems like the only way for many JavaScript coders to deal with browser differences. That’s what i thought ,too, until i read Wrox’s Professional JavaScript for Web Developers (a must-get). The book’s author, Nicholas Zakas, introduces a much more convenient way for dealing with events. It basically involves using a cross-browser event object which creates DOM-like event methods for Internet Explorer.
Read the rest of this entry »
by Mashhoor Al Dubayan
Here’s an example for a script i’ve made today to set ‘odd’ and ‘even’ class names for each <li> element in a list(s). The source code should be self-explanatory, so i guess no explanation is needed here.
by Mashhoor Al Dubayan
This is a script I’ve made earlier that cab make HTML tables a little interactive. It does row color alternation, row hover effect and even highlights a row when you click on it.
I’ve re-coded the script, with designers who can’t code in mind, to make it reusable (thus using lot’s of global variables). Just follow these simple steps to integrate it into your own web page:
Read the rest of this entry »