Stacking Script Event Loaders

I’ve been playing around with JavaScript once when I’ve encountered a problem about my scripts not working, especially those attached to event handlers. You could probably see JavaScript declarations like this on a script or another:

window.onload = functionName;

And, soon, I found out that a lot of plugins I have use the same declaration for initializing their scripts. So, I looked for references and realized that they overwrite one another by declaring that assignment operation over and over again. Looking for solutions, I came across two possible ways to do it:

  1. if (typeof window.onload != 'function') {
    	window.onload = newOnLoadFn;
    } else {
    	var onLoadStack = window.onload;
    	window.onload = function() {
    		onLoadStack();
    		newOnLoadFn();
    	}
    }
  2. var onLoadStack = window.onload;
    window.onload = function() {
    	if (typeof onLoadStack == 'function' && onLoadStack) {
    		onLoadStack();
    	}
    	newOnLoadFn();
    }

Coding preferences applies, as either basically does the same effect of stacking window.onload events. You could put them on a function if you must:

function addOnLoadEvent(newOnLoadFn) {
	if (typeof window.onload != 'function') {
		window.onload = newOnLoadFn;
	} else {
		var onLoadStack = window.onload;
		window.onload = function() {
			onLoadStack();
			newOnLoadFn();
		}
	}
}

And call events using:

addOnLoadEvent(
	// declaration of function type
);

I would recommend anyone distributing scripts to make use of this to avoid conflicts with other event-triggered scripts users may have beside yours. Thanks!

Deprecated HTML Still Taught in High Schools

I was asked for help by my good friend to assist her nephew on his Web page design project. I first asked him what lessons they have discussed in school, so I could match the level of what the teacher taught to what we would be doing. As usual, it included <html>, <head>, and <body> elements, as well as the tables, anchors, images and lists. I was just disappointed when he said they still use <font> tags for changing the size and color of text, and use the <body> attributes background and bgcolor for placing background images and color on the page.

Of course, as a standardista, I hated the fact that I am forced to use deprecated elements and attributes on Web pages. So, I decided to make a statement on this blog hoping to be heard (or read) by computer, web design, and web development teachers in any level of education.

Please, please update yourself on what you know and teach about Web design. HTML 3.2, which you are teaching your depolama students, has been replaced by HTML 4.01 almost 9 years ago. That, in turn, has evden eve nakliyat been reformulated to become XHTML 1.0 in 2000. You should also know that HTML should only be used for structure and CSS be used as its presentational layer.

Web design and development education standardization is one of the things I’d be pushing for in my Web standards advocacy. Education starts in the school. And, if teachers do not know what to teach their students, no advancement would ever happen. In my humble opinion, this principle of educational advancement doesn’t only apply in Web education.

We are still in the process of talking about forming a formal Web standards organization in the Philippines. If you feel the same way as I do in this blog entry, and love to fight for Web standards compliance, join us in our discussions to help save the Web and its users—for interoperability, accessibility, validity, and semantics.

Nearing the end of WordCamp

Matt signs

We ambushed Matt earlier to have him sign my excuse letter and take some photos. Lexie told me I looked like a child on Christmas morning while Matt is signing my letter. 😀

With Sir Regnard

I’m so happy that Web standards was included as a topic in one of the talks specifically by Regnard Raquedan. And I was actually surprised he mentioned me and my blog. Now, I somehow feel pressured to post something about Web standards again. 😛 We are planning to have a meeting later for the Web Standards Philippines group, and I really hope it would again get things going. Thanks Sir Regnard! 😀

Matt is Coming to Town

WordCamp Philippines

WordCamp Philippines 2008 is coming! And I have classes that day! It was really a tough decision to make, since I could have quizzes on the 6th of September 2008, which is a Saturday. I really can’t blame the Mindanao Bloggers who organized the event for the schedule. Besides, I really wanted to thank them for having set the event up. But, since Lexie told me, the hell I care, Matt Mullenweg is coming!

I first heard about this from Shari. She was also planning a meet-up for Web Standards Philippines (a group we set up that has been a little bit neglected for some time because of school), and to finally meet me and Lexie. I do hope WSPh members would participate in this event as well, so as to talk about things, like how we could finally start the group formally. And, most importantly, how we could impart Web standards ideology and advocacy among other bloggers.

So, yeah. I’ve just registered and this would serve as my fee for the event. In line with this, I present to you the sponsors of the event:

Matt, will you sign my excuse letter? 😀

Is Yahoo! under attack?

I could not get onto Yahoo! Messenger right this moment. Even Yahoo! Mail and Web Messenger wouldn’t load. With only a few Yahoo! services I make use of,[1] the only thing I could currently load is the homepage.

I was thinking about a localized network issue on my part since PLDT myDSL has had a lot of negative feedback from subscribers.[2] But my cousin from another city just got online on Gmail with Chat/Google Talk, and though he is on the same provider, I could confirm this isn’t an isolated issue. Unless of course the whole of PLDT’s network couldn’t resolve a connection to select Yahoo! servers.

So, I thought: Is Yahoo! under attack? It is, basically, on a distributed network of servers. So I could think that only the mail and messaging servers were targeted with DoS attacks. Could anybody confirm this?

Losing a heavily used communications tool is much of a hassle for someone like me especially at these times of night. And all those cyber crime in TV shows and news articles I’ve read just fuels my h4x0r imagination.

Ohhhkay. The moment I hit “Publish”, Messenger popped-out having just signed on again. That was weird, but the 2½-hour downtime is still something considering Yahoo! is a very large Internet corporation. So I still ask: Was Yahoo! attacked? Or should I consider changing my Internet Service Provider now? 😛

  1. ^ Those two mentioned above, Messenger and Mail.
  2. ^ Though I am still 95% positive about the service I am getting.