<?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>Xydw Dot Com &#187; table</title>
	<atom:link href="http://www.xydw.com/tag/table/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xydw.com</link>
	<description>php cms, php program,php studio</description>
	<lastBuildDate>Wed, 14 Dec 2011 13:46:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>an idea to fix innerHTML to table in IE (firefox)</title>
		<link>http://www.xydw.com/codes/200905/an-idea-to-fix-innerhtml-to-table-in-ie-firefox/</link>
		<comments>http://www.xydw.com/codes/200905/an-idea-to-fix-innerhtml-to-table-in-ie-firefox/#comments</comments>
		<pubDate>Sat, 09 May 2009 01:40:04 +0000</pubDate>
		<dc:creator>luckymouse</dc:creator>
				<category><![CDATA[Codes & Scripts]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[innerHTML]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://www.xydw.com/?p=105</guid>
		<description><![CDATA[I like to use innerHTML . It is fast and easy to use. But there are some problems under different browsers, such as innerHTML can&#8217;t use to insert to table elements under IE. I have search on google with this issue. There are no good idea to fix innerHTML to table. Someone use Jquery append [...]]]></description>
			<content:encoded><![CDATA[<p>I like to use innerHTML . It is fast and easy to use. But there are some problems under different browsers, such as innerHTML can&#8217;t use to insert to table elements under IE.</p>
<p>I have search on google with this issue. There are no good idea to fix innerHTML to table. Someone use Jquery append to instead. I prefer to use myself script for it is more light weight and fit for me. There are some other ideas beside use libs as Jquery. Someone use &#8220;&lt;div&gt;&#8221; tags between &#8220;&lt;td&gt;&#8221;, then innerHTML to &#8220;&lt;div&gt;&#8221;. This is useful, but can&#8217;t effect on table.  Also we can use InsertRows functions while this is not I prefer. Then how to use innerHTML to table or table elements perfectly ?</p>
<p>Finally, I have an good idea to fix this issue in IE and also tested under firefox. <strong>My idea is to replace whole table</strong>. Table elements are <strong>readonly</strong> under IE. So why we avoid table when use innerHTML ?</p>
<p>Example:</p>
<blockquote><p>&lt;div id=&#8221;mytable&#8221;&gt;<br />
&lt;table&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;domain&lt;/td&gt;<br />
&lt;td&gt;pr&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;xydw.com&lt;/td&gt;<br />
&lt;td&gt;5&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/table&gt;<br />
&lt;/div&gt;</p></blockquote>
<blockquote><p>We would insert a row at bottom.</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
//get table div<br />
<strong> var table = document.getElementById(&#8216;mytable&#8217;);</strong></p>
<p>//store old table data, replace tbody, tbody will auto add under IE<br />
<strong> var old_data = table.innerHTML.replace(/&lt;\/*tbody&gt;/i, &#8221;);</strong></p>
<p>//the data we want to add<br />
<strong> var add_data = &#8216;&lt;tr&gt;&lt;td&gt;lovecms.com&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;/tr&gt;&#8217;;</strong></p>
<p>//new data, find the tag we want to insert<br />
//we insert into end of the table, so find table<br />
//you can insert to anywhere, just find the tag<br />
<strong> var new_data = old_data.replace(/&lt;\/table&gt;/i, add_data + &#8216;&lt;/table&gt;&#8217;);</strong></p>
<p>//use my favourite innerHTML here<br />
//both IE and firefox is OK!<br />
<strong> table.innerHTML = new_data;</strong><br />
&lt;/script&gt;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.xydw.com/codes/200905/an-idea-to-fix-innerhtml-to-table-in-ie-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

