<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sleepiness in Seattle &#187; cross-browser</title>
	<atom:link href="http://stanblog.jojoyao.com/tag/cross-browser/feed/" rel="self" type="application/rss+xml" />
	<link>http://stanblog.jojoyao.com</link>
	<description>Stanley&#039;s Chat on the Technology and Business</description>
	<lastBuildDate>Tue, 21 Apr 2009 04:29:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Cross-browser Event Handler Assignment</title>
		<link>http://stanblog.jojoyao.com/2007/06/cross-browser-event-handler-assignment/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cross-browser-event-handler-assignment</link>
		<comments>http://stanblog.jojoyao.com/2007/06/cross-browser-event-handler-assignment/#comments</comments>
		<pubDate>Wed, 06 Jun 2007 15:17:33 +0000</pubDate>
		<dc:creator>Stanley Yao</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[cross-browser]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://stanblog.jojoyao.com/newblog/?p=44</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<div id="dvAmpBorderBottom" style="DISPLAY: none; FONT-SIZE: 3px; Z-INDEX: 999999; WIDTH: 200px; LINE-HEIGHT: 4px; POSITION: absolute; HEIGHT: 4px; BACKGROUND-COLOR: #ff9900"></div>
<div id="dvAmpBorderTop" style="DISPLAY: none; FONT-SIZE: 3px; Z-INDEX: 999999; WIDTH: 200px; LINE-HEIGHT: 4px; POSITION: absolute; HEIGHT: 4px; BACKGROUND-COLOR: #ff9900"></div>
<div id="dvAmpBorderRight" style="DISPLAY: none; FONT-SIZE: 3px; Z-INDEX: 999999; WIDTH: 4px; LINE-HEIGHT: 4px; POSITION: absolute; HEIGHT: 200px; BACKGROUND-COLOR: #ff9900"></div>
<div id="dvAmpBorderLeft" style="DISPLAY: none; FONT-SIZE: 3px; Z-INDEX: 999999; WIDTH: 4px; LINE-HEIGHT: 4px; POSITION: absolute; HEIGHT: 200px; BACKGROUND-COLOR: #ff9900"></div>
<p>Making the client side scripts work across different major browsers is not easy, especially when client debugging is not as convenient as more strongly typed programming languages.&nbsp; Try the following web page.&nbsp; It works fine on IE but on FireFox clicking the button will trigger nothing to happen.</p>
<table cellspacing="1" cellpadding="1" width="95%" align="center" summary="" border="1">
<tbody>
<tr>
<td><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">html</font><font size="2"> </font><font color="#ff0000" size="2">xmlns</font><font color="#0000ff" size="2">=&quot;http://www.w3.org/1999/xhtml&quot;</font><font size="2"> </font><font color="#0000ff" size="2">&gt;<br />
&lt;</font><font color="#a31515" size="2">head</font><font color="#0000ff" size="2">&gt;</font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">title</font><font color="#0000ff" size="2">&gt;</font><font size="2">Untitled Page</font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">title</font><font color="#0000ff" size="2">&gt;&lt;/</font><font color="#a31515" size="2">head</font><font color="#0000ff" size="2">&gt;<br />
&lt;</font><font color="#a31515" size="2">script</font><font size="2"> </font><font color="#ff0000" size="2">language</font><font color="#0000ff" size="2">=&quot;Javascript&quot;&gt;<br />
function</font><font size="2"> document.onclick() {<br />
&nbsp; alert(</font><font color="#a31515" size="2">&#8216;doc event&#8217;</font><font size="2">);<br />
}<br />
</font><font color="#0000ff" size="2">function</font><font size="2"> foo() {<br />
&nbsp; alert(</font><font color="#a31515" size="2">&#8216;foo&#8217;</font><font size="2">);<br />
}<br />
</font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">script</font><font color="#0000ff" size="2">&gt;<br />
&lt;</font><font color="#a31515" size="2">body</font><font color="#0000ff" size="2">&gt;<br />
&lt;</font><font color="#a31515" size="2">input</font><font size="2"> </font><font color="#ff0000" size="2">type</font><font color="#0000ff" size="2">=&quot;button&quot;</font><font size="2"> </font><font color="#ff0000" size="2">value</font><font color="#0000ff" size="2">=&quot;ok&quot;</font><font size="2"> </font><font color="#ff0000" size="2">onclick</font><font color="#0000ff" size="2">=&quot;foo();&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;<br />
&lt;/</font><font color="#a31515" size="2">body</font><font color="#0000ff" size="2">&gt;<br />
&lt;/</font><font color="#a31515" size="2">html</font><font color="#0000ff" size="2">&gt;</font></td>
</tr>
</tbody>
</table>
<p>The page will silently fail and none of the event handlers works.&nbsp; Change the document.onclick handler assignment into the following and it works on both browsers.&nbsp; Tools like the Error Console on FireFox is very helpful in diagnosing these type of errors.</p>
<table cellspacing="1" cellpadding="1" width="95%" align="center" summary="" border="1">
<tbody>
<tr>
<td><font color="#0000ff" size="2">&#8230;<br />
</font><font size="2">document.onclick = function () {<br />
&nbsp; alert(</font><font color="#a31515" size="2">&#8216;doc event&#8217;</font><font size="2">);<br />
}<br />
&#8230;</font></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://stanblog.jojoyao.com/2007/06/cross-browser-event-handler-assignment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

