<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The dangers of embedding the notorious &#8220;void(0)&#8221; JavaScript code in the href attribute of the &#8220;a&#8221; tag</title>
	<atom:link href="http://www.randomsnippets.com/2009/04/08/the-dangers-of-embedding-the-notorious-void0-javascript-code-in-the-href-attribute-of-the-a-tag/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.randomsnippets.com/2009/04/08/the-dangers-of-embedding-the-notorious-void0-javascript-code-in-the-href-attribute-of-the-a-tag/</link>
	<description>Random Snippets of Code and Ideas for any Web Developer</description>
	<lastBuildDate>Sat, 17 Jul 2010 11:08:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Knix</title>
		<link>http://www.randomsnippets.com/2009/04/08/the-dangers-of-embedding-the-notorious-void0-javascript-code-in-the-href-attribute-of-the-a-tag/comment-page-1/#comment-5593</link>
		<dc:creator>Knix</dc:creator>
		<pubDate>Wed, 05 Aug 2009 14:28:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/?p=212#comment-5593</guid>
		<description>You are right.  There are actually a lot of things wrong with this post and I do regret writing it.  Using &#039;#&#039; is definitely not the way to go.  I will probably rewrite this one day using your recommendation amongst other versions.  Thanks for your feedback.</description>
		<content:encoded><![CDATA[<p>You are right.  There are actually a lot of things wrong with this post and I do regret writing it.  Using &#8216;#&#8217; is definitely not the way to go.  I will probably rewrite this one day using your recommendation amongst other versions.  Thanks for your feedback.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ulrich</title>
		<link>http://www.randomsnippets.com/2009/04/08/the-dangers-of-embedding-the-notorious-void0-javascript-code-in-the-href-attribute-of-the-a-tag/comment-page-1/#comment-5592</link>
		<dc:creator>Ulrich</dc:creator>
		<pubDate>Wed, 05 Aug 2009 14:21:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/?p=212#comment-5592</guid>
		<description>I think the best way to do this is
href=&quot;alternativelink&quot; onclick=&quot;dosomething(); return false;&quot;
If someone has javascript enabled, dosomething() will be executed.
If javascript was disabled by the user, you provide an alternative with alternativelink. This is especially important, if you want to open a new page/image in a new window for example. Many people want to open the page or image in a new tab and use middle click on the link. But this only works if you provide alternativelink.</description>
		<content:encoded><![CDATA[<p>I think the best way to do this is<br />
href=&#8221;alternativelink&#8221; onclick=&#8221;dosomething(); return false;&#8221;<br />
If someone has javascript enabled, dosomething() will be executed.<br />
If javascript was disabled by the user, you provide an alternative with alternativelink. This is especially important, if you want to open a new page/image in a new window for example. Many people want to open the page or image in a new tab and use middle click on the link. But this only works if you provide alternativelink.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rosuav</title>
		<link>http://www.randomsnippets.com/2009/04/08/the-dangers-of-embedding-the-notorious-void0-javascript-code-in-the-href-attribute-of-the-a-tag/comment-page-1/#comment-3258</link>
		<dc:creator>Rosuav</dc:creator>
		<pubDate>Sun, 03 May 2009 17:14:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/?p=212#comment-3258</guid>
		<description>You don&#039;t need to use PHP for that; just use href=&quot;#&quot; for that purpose. But this has the annoying side effect of snapping the cursor up to the top of the page. This can be cured by altering the onclick to return false:

a href=&quot;#&quot; onclick=&quot;dosomething(); return false;&quot;

Alternatively, have dosomething() return false, and use

a href=&quot;#&quot; onclick=&quot;return dosomething();&quot;

Personally, I prefer to use this format:

a href=&quot;javascript:dosomething()&quot;

This doesn&#039;t navigate away from the page in modern browsers - and let&#039;s face it, who cares about supporting Netscape 4.04 these days? Browsers that old are pretty much not-found, if you&#039;ll excuse the pun!</description>
		<content:encoded><![CDATA[<p>You don&#8217;t need to use PHP for that; just use href=&#8221;#&#8221; for that purpose. But this has the annoying side effect of snapping the cursor up to the top of the page. This can be cured by altering the onclick to return false:</p>
<p>a href=&#8221;#&#8221; onclick=&#8221;dosomething(); return false;&#8221;</p>
<p>Alternatively, have dosomething() return false, and use</p>
<p>a href=&#8221;#&#8221; onclick=&#8221;return dosomething();&#8221;</p>
<p>Personally, I prefer to use this format:</p>
<p>a href=&#8221;javascript:dosomething()&#8221;</p>
<p>This doesn&#8217;t navigate away from the page in modern browsers &#8211; and let&#8217;s face it, who cares about supporting Netscape 4.04 these days? Browsers that old are pretty much not-found, if you&#8217;ll excuse the pun!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin</title>
		<link>http://www.randomsnippets.com/2009/04/08/the-dangers-of-embedding-the-notorious-void0-javascript-code-in-the-href-attribute-of-the-a-tag/comment-page-1/#comment-3101</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Wed, 29 Apr 2009 05:26:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/?p=212#comment-3101</guid>
		<description>Alternatively, you could use onclick with  rather than &lt;a&gt; and you won&#039;t have to worry about the user being redirected anyplace or use the # in the href attribute.</description>
		<content:encoded><![CDATA[<p>Alternatively, you could use onclick with  rather than <a> and you won&#8217;t have to worry about the user being redirected anyplace or use the # in the href attribute.</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
