<?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>The Error Message &#187; JavaScript</title>
	<atom:link href="http://www.theerrormessage.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theerrormessage.com</link>
	<description>Fix your error</description>
	<lastBuildDate>Sun, 18 Jul 2010 03:21:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>base html tag does not apply correctly to all javascript and style files</title>
		<link>http://www.theerrormessage.com/2009/07/base-html-tag-does-not-apply-correctly-to-all-javascript-and-style-files/</link>
		<comments>http://www.theerrormessage.com/2009/07/base-html-tag-does-not-apply-correctly-to-all-javascript-and-style-files/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 15:21:40 +0000</pubDate>
		<dc:creator>gbl</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.theerrormessage.com/2009/07/03/base-html-tag-does-not-apply-correctly-to-all-javascript-and-style-files/</guid>
		<description><![CDATA[Problem: The &#60;base href="http://example.com/path/to/res/"&#62;  did not work at all on Internet Explorer &#8211; no javascript or style files were loaded and worked partially in Mozilla Firefox &#8211; a few javascript files were not pointing to the path that should be transformed by base href attribute. Example: Array( [0] =&#62; 1 ) &#60;!DOCTYPE html PUBLIC "-//W3C//DTD [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong>: The <code class="html">&lt;base href="http://example.com/path/to/res/"&gt;</code>  did not work at all on Internet Explorer &#8211; no javascript or style files were loaded and worked partially in Mozilla Firefox &#8211; a few javascript files were not pointing to the path that should be transformed by base href attribute.</p>
<p>Example:<br />
<code class="html"><br />
Array(<br />
[0] =&gt; 1<br />
)<br />
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br />
&lt;base href="http://example.com/path/to/res/"&gt;<br />
&lt;link rel="stylesheet" href="./css/styles.css" type="text/css" /&gt;<br />
&lt;scrupt src="./js/jquery.js" type="text/javascript"&gt;&lt;/script&gt;<br />
&lt;scrupt src="./js/j1.js" type="text/javascript"&gt;&lt;/script&gt;<br />
&lt;scrupt src="./js/j2.js" type="text/javascript"&gt;&lt;/script&gt;<br />
</code><br />
This code produced a page with no style files and  no javascript files included in Interenet Explorer 8 and a few javascript files (j1.js and j2.js) were not included in Firefox 3.5 because base tag was not applied. After several tests and all kind of different arrangements we discovered that the problem was the output before the page source the <code>Array ...</code> thing.</p>
<p><strong>Solution</strong>: no output before the page&#8217;s headers otherwise you can get all kind of strange results including a html base tag not working correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theerrormessage.com/2009/07/base-html-tag-does-not-apply-correctly-to-all-javascript-and-style-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Object doesn&#8217;t support property or method. Adding options in a &lt;select&gt; from a child window on Internet Explorer</title>
		<link>http://www.theerrormessage.com/2009/03/object-doesnt-support-property-or-method-adding-options-in-a-select-from-a-child-window-on-internet-explorer/</link>
		<comments>http://www.theerrormessage.com/2009/03/object-doesnt-support-property-or-method-adding-options-in-a-select-from-a-child-window-on-internet-explorer/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 01:55:36 +0000</pubDate>
		<dc:creator>gbl</dc:creator>
				<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.theerrormessage.com/2009/03/17/object-doesnt-support-property-or-method-adding-options-in-a-from-a-child-window-on-internet-explorer/</guid>
		<description><![CDATA[Full error message:  Object doesn&#8217;t support property or method. I got this error message in Internet Explorer 7 every time i tried to run code similar to the next snippet: window.opener.form.select[select.length]  = new Option(text, value); The problem is that on Internet Explorer due to some mysterious security restrictions you are not allowed to add new [...]]]></description>
			<content:encoded><![CDATA[<p>Full error message:  <em>Object doesn&#8217;t support property or method</em>. I got this error message in Internet Explorer 7 every time i tried to run code similar to the next snippet:</p>
<p><code class="javascript">window.opener.form.select[select.length]  = new Option(text, value);</code></p>
<p>The problem is that on Internet Explorer due to some mysterious security restrictions you are not allowed to add new options in a select element that resides in the parent (opener) window. In order to do this you need a workaround.</p>
<p>The easiest <strong>workaround</strong> is to <strong>write a function in the parent window that adds elements in the select element</strong>. The function should look something like this:</p>
<p><code class="javascript">function addOptionToSelect(formName, selectName, optionText, optionValue) {<br />
var elem = document.forms[formName].elements[selectName];<br />
elem.options[elem.length] = new Option(optionText, optionValue);<br />
}</code></p>
<p>This function has to be written in the parent window&#8217;s javascript and it will be accessed from child window with some code like this:</p>
<p><code class="javascript">window.opener.addOptionToSelect(formName, selectName, optionText, optioValue);</code></p>
<p><strong>Conclusion:</strong> Internet Explorer sucks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theerrormessage.com/2009/03/object-doesnt-support-property-or-method-adding-options-in-a-select-from-a-child-window-on-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jquery pngFix fixed</title>
		<link>http://www.theerrormessage.com/2009/03/jquery-pngfix-fixed/</link>
		<comments>http://www.theerrormessage.com/2009/03/jquery-pngfix-fixed/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 05:00:31 +0000</pubDate>
		<dc:creator>gbl</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.theerrormessage.com/2009/03/11/jquery-pngfix-fixed/</guid>
		<description><![CDATA[I tried to use the pngFix from this website: http://jquery.andreaseberhard.de/pngFix/. But it didn&#8217;t work and i received an javascript error in IE6. After several minutes of debugging and tries i found out that the error is generated by old syntax in selecting elements. It used jQuery(this).find("img[@src$=.png]").each(...); instead of jQuery(this).find("img[src$=.png]").each(...); So the fix is: Remove the [...]]]></description>
			<content:encoded><![CDATA[<p>I tried to use the pngFix from this website: <a href="http://jquery.andreaseberhard.de/pngFix/" target="_blank">http://jquery.andreaseberhard.de/pngFix/</a>. But it didn&#8217;t work and i received an javascript error in IE6.</p>
<p>After several minutes of debugging and tries i found out that the error is generated by old syntax in selecting elements. It used <code class="javascript">jQuery(this).find("img[@src$=.png]").each(...);</code> instead of <code class="javascript">jQuery(this).find("img[src$=.png]").each(...);</code></p>
<p>So <strong>the fix</strong> is: <strong>Remove the &#8220;@&#8221; character form the selector string. </strong></p>
<p>The same thing for the &#8220;pack&#8221; version except that the replaced string is: <code class="javascript">[@m$=.M]</code> and the  replacement string is: <code class="javascript">[m$=.M]</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theerrormessage.com/2009/03/jquery-pngfix-fixed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to check/uncheck a bunch of checkboxes without using ids for the checkbox inputs</title>
		<link>http://www.theerrormessage.com/2007/12/how-to-selectdeselect-a-bunch-of-checkboxes-without-using-ids-for-the-checkbox-inputs/</link>
		<comments>http://www.theerrormessage.com/2007/12/how-to-selectdeselect-a-bunch-of-checkboxes-without-using-ids-for-the-checkbox-inputs/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 18:21:04 +0000</pubDate>
		<dc:creator>thalissar</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.theerrormessage.com/2007/12/09/how-to-selectdeselect-a-bunch-of-checkboxes-without-using-ids-for-the-checkbox-inputs/</guid>
		<description><![CDATA[My solution of checking/unchecking a group of HTML checkboxes using Javascript implies using an array of checkboxes, which means naming all the inputs of type &#8216;checkbox&#8217; like array_name[]. Example: &#60;form name="cb_form"&#62; &#60;input type="checkbox" name="cb[]" value="0" /&#62;Zero &#60;input type="checkbox" name="cb[]" value="1" /&#62;One &#60;input type="checkbox" name="cb[]" value="2" /&#62;Two &#60;input type="checkbox" name="cb[]" value="3" /&#62;Three &#60;/form&#62; In this example, [...]]]></description>
			<content:encoded><![CDATA[<p>My solution of checking/unchecking a group of HTML checkboxes using Javascript implies using an array of checkboxes, which means naming all the inputs of type &#8216;checkbox&#8217; like <em>array_name[]</em>. Example:</p>
<p><code class="html">&lt;form name="cb_form"&gt;<br />
&lt;input type="checkbox" name="cb[]" value="0" /&gt;Zero<br />
&lt;input type="checkbox" name="cb[]" value="1" /&gt;One<br />
&lt;input type="checkbox" name="cb[]" value="2" /&gt;Two<br />
&lt;input type="checkbox" name="cb[]" value="3" /&gt;Three<br />
&lt;/form&gt;</code></p>
<p>In this example, the name of the checkboxes array is <em>cb</em>.</p>
<p>Next, we place two links for checking/unchecking all checkboxes in our array. If someone clicks one of these links, the <em>check</em><em>All()</em> JavaScript function is called:</p>
<p><code class="html">&lt;a href="" onclick="checkAll('cb_form', 'cb[]', true); return false;"&gt;Check all&lt;a&gt;<br />
&lt;a href="" onclick="checkAll('cb_form', 'cb[]', false); return false;"&gt;Uncheck all&lt;a&gt;</code></p>
<p>The checking/unchecking all checkboxes function in JavaScipt looks like this:</p>
<p><code class="javascript">function checkAll(form_name, cb_name, value)<br />
{<br />
var cb_arr = document.forms[form_name].elements[cb_name];<br />
// if the checkboxes exist<br />
if(cb_arr)<br />
{<br />
// if the number of checkboxes is at least 2<br />
if(cb_arr.length &gt; 1)<br />
{<br />
// for each checkbox<br />
for(i = 0; i &lt; cb_arr.length; i++)<br />
{<br />
// check (value == true) or uncheck (value == false) it<br />
cb_arr[i].checked = value;<br />
}<br />
}<br />
else // cb_arr.length is undefined which means there is a single checkbox element that is not considered an array of one element<br />
{<br />
cb_arr.checked = value;<br />
}<br />
}<br />
}<br />
</code><br />
Note that if we only have one checkbox, the variable <em>cb</em> it is not considered an array, but a normal variable. This is useful in the situation of dinamically generated HTML pages (using PHP, for example) and the number of checkboxes varies from page to page.</p>
<p>You can test the example here:</p>
<p><script type="text/javascript"> function selectAll(form_name, cb_name, value) { var cb_arr = document.forms[form_name].elements[cb_name]; if(cb_arr) { if(cb_arr.length > 1) { for(i = 0; i < cb_arr.length; i++) { cb_arr[i].checked = value; } } else if(cb_arr.length == 1) { cb_arr.checked = value; } } } </script></p>
<form name="cb_form">
<input name="cb[]" value="0" type="checkbox" />Zero<br />
<input name="cb[]" value="1" type="checkbox" />One<br />
<input name="cb[]" value="2" type="checkbox" />Two<br />
<input name="cb[]" value="3" type="checkbox" /> Three<br />
</form>
<p><a onclick="selectAll('cb_form', 'cb[]', true); return false;" style="color: #000000; text-decoration: underline; cursor: pointer">Check all</a> <a onclick="selectAll('cb_form', 'cb[]', false); return false;" style="color: #000000; text-decoration: underline; cursor: pointer">Uncheck all</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.theerrormessage.com/2007/12/how-to-selectdeselect-a-bunch-of-checkboxes-without-using-ids-for-the-checkbox-inputs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
