<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Setting Input Values through innerHTML in&#160;Safari</title>
	<atom:link href="http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/feed/" rel="self" type="application/rss+xml" />
	<link>http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/</link>
	<description>Everyone needs a hug.</description>
	<pubDate>Sun, 12 Oct 2008 15:21:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Mark Rowe</title>
		<link>http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15833</link>
		<dc:creator>Mark Rowe</dc:creator>
		<pubDate>Tue, 06 Feb 2007 01:32:57 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15833</guid>
		<description>&lt;p&gt;Note that this particular issue is fix in the newest versions of WebKit, Safari's HTML rendering engine.  You can grab a &lt;a href='http://nightly.webkit.org/' rel="nofollow"&gt;nightly build of WebKit&lt;/a&gt; and verify that your original code works as you would expect.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Note that this particular issue is fix in the newest versions of WebKit, Safari&#8217;s HTML rendering engine.  You can grab a <a href='http://nightly.webkit.org/' rel="nofollow">nightly build of WebKit</a> and verify that your original code works as you would expect.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Nephilim</title>
		<link>http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15823</link>
		<dc:creator>Nephilim</dc:creator>
		<pubDate>Tue, 06 Feb 2007 00:43:28 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15823</guid>
		<description>&lt;p&gt;Using += is not the problem.  You'd have the same problem with, say, i = i + j.&lt;/p&gt;

&lt;p&gt;The problem is that when Safari passes back the innerHTML, they give you the string &lt;i&gt;with the html entities inside the tag properties decoded&lt;/i&gt;.  In other words, when you query the innerHTML, those quote entities come back as quote literals.&lt;/p&gt;

&lt;p&gt;If you want to re-submit them to Safari's DOM, then, you'll need to re-escape them using regular expressions or something.  Otherwise, you get semi-unpredictable results, as you saw, as Safari tries to parse what you mean by having quote marks in the wrong places.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Using += is not the problem.  You&#8217;d have the same problem with, say, i = i + j.</p>

<p>The problem is that when Safari passes back the innerHTML, they give you the string <i>with the html entities inside the tag properties decoded</i>.  In other words, when you query the innerHTML, those quote entities come back as quote literals.</p>

<p>If you want to re-submit them to Safari&#8217;s DOM, then, you&#8217;ll need to re-escape them using regular expressions or something.  Otherwise, you get semi-unpredictable results, as you saw, as Safari tries to parse what you mean by having quote marks in the wrong places.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Bramus!</title>
		<link>http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15774</link>
		<dc:creator>Bramus!</dc:creator>
		<pubDate>Mon, 05 Feb 2007 20:37:56 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15774</guid>
		<description>&lt;p&gt;Couldn't pinpoint the problem either ... great find and writeup!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Couldn&#8217;t pinpoint the problem either &#8230; great find and writeup!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Heilmann</title>
		<link>http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15749</link>
		<dc:creator>Chris Heilmann</dc:creator>
		<pubDate>Mon, 05 Feb 2007 17:41:12 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15749</guid>
		<description>&lt;p&gt;@George,&lt;/p&gt;

&lt;p&gt;MSIE is only a symptom, the cause is that string concatenation is always pricy. If you &lt;a href="http://www.google.co.uk/search?hl=en&#38;safe=off&#38;q=string+concatenation+speed&#38;btnG=Search&#38;meta=" rel="nofollow"&gt;search for string concatenation&lt;/a&gt; you find workarounds for the += problem in almost any language: Java, C#, Python, JavaScript, even Pascal :). 
You are running into doors if you tell me that we shouldn't hack around MSIE's inefficiencies, but this is a general programming problem of the memory allocation strings get in comparison to adding to an Array.
&lt;a href="http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=JavascriptStringConcatenation" rel="nofollow"&gt;Firefox has the same problem&lt;/a&gt;, not to the same extend, but it has.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@George,</p>

<p>MSIE is only a symptom, the cause is that string concatenation is always pricy. If you <a href="http://www.google.co.uk/search?hl=en&amp;safe=off&amp;q=string+concatenation+speed&amp;btnG=Search&amp;meta=" rel="nofollow">search for string concatenation</a> you find workarounds for the += problem in almost any language: Java, C#, Python, JavaScript, even Pascal :). 
You are running into doors if you tell me that we shouldn&#8217;t hack around MSIE&#8217;s inefficiencies, but this is a general programming problem of the memory allocation strings get in comparison to adding to an Array.
<a href="http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=JavascriptStringConcatenation" rel="nofollow">Firefox has the same problem</a>, not to the same extend, but it has.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: George</title>
		<link>http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15725</link>
		<dc:creator>George</dc:creator>
		<pubDate>Mon, 05 Feb 2007 16:11:30 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15725</guid>
		<description>&lt;p&gt;@Chris&lt;/p&gt;

&lt;p&gt;It's funny... += to build a string is commonplace, but because MSIE doesn't handle it well, we are "recommended" to change our code to suit their inefficiencies?  I'm all for optimizing code, and making it clean, but sometimes tweaking to enhance the MSIE experience seems over gracious for a browser that doesn't do much to help the developers.&lt;/p&gt;

&lt;p&gt;The correct answer, is that Microsoft should &lt;em&gt;fix&lt;/em&gt; their code, to make += concatenation work properly, without huge memory issues.  String manipulation is something that should just zip along in browsers made in 2005+.  Creating an Array (temp object), then calling dozens of methods on it to push the content size... then another to join it all back into one string is just silly.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Chris</p>

<p>It&#8217;s funny&#8230; += to build a string is commonplace, but because MSIE doesn&#8217;t handle it well, we are &#8220;recommended&#8221; to change our code to suit their inefficiencies?  I&#8217;m all for optimizing code, and making it clean, but sometimes tweaking to enhance the MSIE experience seems over gracious for a browser that doesn&#8217;t do much to help the developers.</p>

<p>The correct answer, is that Microsoft should <em>fix</em> their code, to make += concatenation work properly, without huge memory issues.  String manipulation is something that should just zip along in browsers made in 2005+.  Creating an Array (temp object), then calling dozens of methods on it to push the content size&#8230; then another to join it all back into one string is just silly.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Campbell</title>
		<link>http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15724</link>
		<dc:creator>Ryan Campbell</dc:creator>
		<pubDate>Mon, 05 Feb 2007 16:09:21 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15724</guid>
		<description>&lt;p&gt;Good call. I just ran some quick speed tests and noticed a 1 to 3 millisecond improvement on strings with roughly 250 characters in Safari. I'll test some more in IE later to see what I can come up with. For larger strings, the improvement is deifnitely worth it.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Good call. I just ran some quick speed tests and noticed a 1 to 3 millisecond improvement on strings with roughly 250 characters in Safari. I&#8217;ll test some more in IE later to see what I can come up with. For larger strings, the improvement is deifnitely worth it.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Heilmann</title>
		<link>http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15709</link>
		<dc:creator>Chris Heilmann</dc:creator>
		<pubDate>Mon, 05 Feb 2007 15:21:39 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/setting-input-values-through-innerhtml-in-safari/#comment-15709</guid>
		<description>&lt;p&gt;It is generally a bad idea to concatenate strings with += because of MSIE's bad memory handling of strings. The safer (and a lot quicker for large strings - with 10000 characters MSIE might lock up for up to 15 minutes) way is to push the data into an array and join the array before writing out the HTML.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>It is generally a bad idea to concatenate strings with += because of MSIE&#8217;s bad memory handling of strings. The safer (and a lot quicker for large strings - with 10000 characters MSIE might lock up for up to 15 minutes) way is to push the data into an array and join the array before writing out the HTML.</p>]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.239 seconds -->
