<?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>.NET Tips and Tricks &#187; Browser</title>
	<atom:link href="http://kossovsky.net/index.php/category/browser/feed/" rel="self" type="application/rss+xml" />
	<link>http://kossovsky.net</link>
	<description>C# Code Snippets, ASP.NET Code Samples, .NET Tips and Tricks</description>
	<lastBuildDate>Sat, 25 Dec 2010 08:32:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Script as blocking element and dynamic script loading using document.write</title>
		<link>http://kossovsky.net/index.php/2009/07/script-as-blocking-element-and-dynamic-script-loading-using-document-write/</link>
		<comments>http://kossovsky.net/index.php/2009/07/script-as-blocking-element-and-dynamic-script-loading-using-document-write/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 11:44:20 +0000</pubDate>
		<dc:creator>Maxim</dc:creator>
				<category><![CDATA[Browser]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[blocking]]></category>
		<category><![CDATA[blocking elements]]></category>
		<category><![CDATA[div style]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[dynamic element]]></category>
		<category><![CDATA[element content]]></category>
		<category><![CDATA[endless times]]></category>
		<category><![CDATA[flow]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[loading]]></category>
		<category><![CDATA[lt]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[script block]]></category>
		<category><![CDATA[script loading]]></category>
		<category><![CDATA[script type]]></category>
		<category><![CDATA[static element]]></category>
		<category><![CDATA[web page]]></category>
		<category><![CDATA[write]]></category>

		<guid isPermaLink="false">http://kossovsky.net/?p=652</guid>
		<description><![CDATA[We all know that script is blocking element, meaning no content will be rendered untill script block is parsed and executed or downloaded then parsed and then executed in case of externale script. And we were told endless times that the best practice is to load scripts at the end of web page. It&#8217;s true. [...]<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (3 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>We all know that <strong>script</strong> is blocking element, meaning no content will be rendered untill script block is parsed and executed or downloaded then parsed and then executed in case of externale script.</p>
<p>And we were told endless times that the best practice is to load scripts at the end of web page. It&#8217;s true. </p>
<p>We also have <strong>document.ready</strong> events thanks to numerous javascript frameworks that gives us opportunity to perform most of our JS actions when document is ready to be manipulated. But there are cases when you do need JS blocking features.<br />
<span id="more-652"></span><br />
Many ad serving systems work using <strong>document.write</strong> (One I&#8217;m have very good knowledge of is RealMedia), sometimes you need to load different versions of your scripts or your content rendering depends on some script and you have to be sure nothing is loaded untill your script is ready or may be you have script that depends on some script and you are not sure that this framework is loaded. Here comes <strong>document.write</strong> to your assistance.</p>
<p>I&#8217;m sure many people will say that I can load scripts using appendElement and then load depending scripts on it&#8217;s <strong>load</strong> event. This is also true, may be in my next post I will talk about this kind of script loading. But now lets see some samples.</p>
<p>Example #1</p>
<pre name="code" class="html">
	&lt;div style="border: 1px solid blue;width:200px;padding:10px;">
		Static element content
		&lt;script type="text/javascript">
			document.write("&lt;script type=\"text\/javascript\"
                                 src=\"writeContent.js\">&lt;\/script>");
		&lt;/script>
	&lt;/div>
</pre>
<p>Content of the writeContent.js file:</p>
<pre name="code" class="javascript">
document.write("&lt;div style=\"border:1px solid red;width:200px;\">
     Dynamic element content&lt;\/div>")
</pre>
<p>The result is pretty obvious:<br />
<img src="http://kossovsky.net/wp-content/uploads/2009/07/s1_1.gif" alt="Sample #1 - HTML Result" title="s1_1" width="238" height="82" class="size-full wp-image-659" /></p>
<p>In our next example we have some JS in in writeVariable.js file and we want to load and use it:</p>
<pre name="code" class="html">
&lt;div>
	&lt;script type="text/javascript">
		document.write("&lt;script type=\"text\/javascript\"
                      src=\"writeVariable.js\">&lt;\/script>");
		alert(myVar);
	&lt;/script>
&lt;/div>
</pre>
<p>Content of the writeContent.js file:</p>
<pre name="code" class="javascript">
    var myVar = "Some value";
</pre>
<p>You would expect to see alert  &#8220;Some value&#8221; but actually you will get &#8220;myVar is undefined&#8221; error. Why? Look at the HTML structure created and understand why:<br />
<img src="http://kossovsky.net/wp-content/uploads/2009/07/s2_1.gif" alt="Example #2 HTML structure" title="Example #2 HTML structure" width="202" height="48" class="alignnone size-full wp-image-665" /></p>
<p>Script block that you wrote created right after script block that was executed, so obviously at the time you tried to alert <strong>myVar</strong> it didn&#8217;t exist in the document.</p>
<p>The correct way to write it would be:</p>
<pre name="code" class="html">
	&lt;div&gt;
		&lt;script type="text/javascript"&gt;
                      document.write("&lt;script type=\"text/javascript\"
                           src=\"writeVariable.js\">&lt;\/script&gt;");
		&lt;/script&gt;
		&lt;script type="text/javascript"&gt;
                       alert(myVar);
		&lt;/script&gt;
	&lt;/div&gt;
</pre>
<p>You need to split your script into two blocks one writing the script and then second one using its data.</p>
<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (3 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fkossovsky.net%2Findex.php%2F2009%2F07%2Fscript-as-blocking-element-and-dynamic-script-loading-using-document-write%2F" layout="standard" show_faces="false" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://kossovsky.net/index.php/2009/07/script-as-blocking-element-and-dynamic-script-loading-using-document-write/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Javascript boolean interpretation</title>
		<link>http://kossovsky.net/index.php/2009/07/javascript-boolean-interpretation/</link>
		<comments>http://kossovsky.net/index.php/2009/07/javascript-boolean-interpretation/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 08:16:27 +0000</pubDate>
		<dc:creator>Maxim</dc:creator>
				<category><![CDATA[Browser]]></category>
		<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[about true]]></category>
		<category><![CDATA[alert message]]></category>
		<category><![CDATA[boolean interpretation]]></category>
		<category><![CDATA[boolean values]]></category>
		<category><![CDATA[document write]]></category>
		<category><![CDATA[eval]]></category>
		<category><![CDATA[javascript boolean]]></category>
		<category><![CDATA[javascript browser]]></category>
		<category><![CDATA[principle]]></category>
		<category><![CDATA[simple questions]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://kossovsky.net/?p=613</guid>
		<description><![CDATA[How to deal with JavaScript boolean values, what will be evaluated as true and what as false !!!!.<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (5 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>I have two simple questions for you about boolean values in Javascript.<br />
When will  browser show alert message:</p>
<pre class="javascript" name="code">
        if (a-b) alert("it's true!");
</pre>
<p>And another one<br />
<span id="more-613"></span><br />
What will be printed as result of running this script:</p>
<pre class="javascript" name="code">
	for (var n=10; n; n-- )
	{
		document.write (n + ",");
	}
</pre>
<p>The answer for both questions relies on the same principle of what JavaScript engine will evaluate as true and what as false.</p>
<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (5 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fkossovsky.net%2Findex.php%2F2009%2F07%2Fjavascript-boolean-interpretation%2F" layout="standard" show_faces="false" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://kossovsky.net/index.php/2009/07/javascript-boolean-interpretation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>IETester &#8211; Multiple Internet Explorer versions on the same PC</title>
		<link>http://kossovsky.net/index.php/2009/06/ietester-multiple-internet-explorer-versions-on-the-same-pc/</link>
		<comments>http://kossovsky.net/index.php/2009/06/ietester-multiple-internet-explorer-versions-on-the-same-pc/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 20:18:24 +0000</pubDate>
		<dc:creator>Xander</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Browser]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[QA]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[browser web]]></category>
		<category><![CDATA[Cross Browser]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[ie5 5]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[IE8]]></category>
		<category><![CDATA[internet explorer versions]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[little bugs]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[virtual server]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[web developer]]></category>
		<category><![CDATA[webbrowser]]></category>

		<guid isPermaLink="false">http://kossovsky.net/?p=171</guid>
		<description><![CDATA[IETester is a free WebBrowser that allows you to have the rendering and javascript engines of IE8, IE7 IE 6 and IE5.5 on Vista and XP, as well as the installed IE in the same process. Despite some little bugs IETester is a very nice tool and for my opinion this is a must for [...]<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (5 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-173" title="IETester" src="http://kossovsky.net/wp-content/uploads/2009/06/ietester-0_3.jpg" alt="IETester" width="400" height="112" /></p>
<p>IETester is a<strong> free</strong> WebBrowser that allows you to have the rendering and javascript engines of IE8, IE7 IE 6 and IE5.5 on Vista and XP, as well as the installed IE in the same process.<span id="more-171"></span></p>
<p>Despite some little bugs <a title="IETester" href="http://www.my-debugbar.com/wiki/IETester/HomePage" target="_blank">IETeste</a>r is a very nice tool and for my opinion this is a must for any web developer who makes cross browser web sites and don&#8217;t want to install virtual server for each IE version.</p>
<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (5 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fkossovsky.net%2Findex.php%2F2009%2F06%2Fietester-multiple-internet-explorer-versions-on-the-same-pc%2F" layout="standard" show_faces="false" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://kossovsky.net/index.php/2009/06/ietester-multiple-internet-explorer-versions-on-the-same-pc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

