<?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>Bright Cherry &#187; Javascript</title>
	<atom:link href="http://www.brightcherry.co.uk/scribbles/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brightcherry.co.uk/scribbles</link>
	<description></description>
	<lastBuildDate>Tue, 20 Dec 2011 19:54:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Javascript &#8211; Get The Hash Tag Value From A URL</title>
		<link>http://www.brightcherry.co.uk/scribbles/jquery-get-the-hash-tag-value-from-a-url/</link>
		<comments>http://www.brightcherry.co.uk/scribbles/jquery-get-the-hash-tag-value-from-a-url/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 17:47:35 +0000</pubDate>
		<dc:creator>adm1n</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=421</guid>
		<description><![CDATA[So, you have the following URL: http://www.example.com/page/#comment-12 You want to get the value after the hash tag (#), which is comment-12 The following Javascript code will help you achieve what you&#8217;re after: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 &#160; &#60;script type=&#34;text/javascript&#34;&#62; &#160; //check if hash tag exists [...]]]></description>
			<content:encoded><![CDATA[<p>So, you have the following URL:</p>
<p><b class="pink">http://www.example.com/page/#comment-12</b></p>
<p>You want to get the value after the hash tag (#), which is <b>comment-12</b></p>
<p>The following Javascript code will help you achieve what you&#8217;re after:</p>

<div class="wp_codebox"><table><tr id="p4212"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p421code2"><pre class="js" style="font-family:monospace;">&nbsp;
&lt;script type=&quot;text/javascript&quot;&gt;
&nbsp;
//check if hash tag exists in the URL
if(window.location.hash) {
&nbsp;
 //set the value as a variable, and remove the #
 var hash_value = window.location.hash.replace('#', '');
&nbsp;
 //show the value with an alert pop-up
 alert(hash_value);
&nbsp;
}
&lt;/script&gt;</pre></td></tr></table></div>

<p>That&#8217;s it. It&#8217;s as easy that.</p>
<p>Please let me know if it did or didn&#8217;t work for you. Alternatively, if you know of a better way to achieve the same output. Thanks in advance!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brightcherry.co.uk/scribbles/jquery-get-the-hash-tag-value-from-a-url/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Javascript &#8211; Make Div Into A Clickable Link</title>
		<link>http://www.brightcherry.co.uk/scribbles/javascript-make-div-into-a-clickable-link/</link>
		<comments>http://www.brightcherry.co.uk/scribbles/javascript-make-div-into-a-clickable-link/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 10:53:56 +0000</pubDate>
		<dc:creator>adm1n</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=358</guid>
		<description><![CDATA[From what I&#8217;m aware, you can&#8217;t make a div into a clickable link with just HTML. The only way I&#8217;ve ever known is by using Javascript. Open in new window Here&#8217;s how to make a div into a clickable link that will open the target URL into a new window. 1 2 3 4 &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>From what I&#8217;m aware, you can&#8217;t make a div into a clickable link with just HTML. The only way I&#8217;ve ever known is by using Javascript.</p>
<h4>Open in new window</h4>
<p>Here&#8217;s how to make a div into a clickable link that will open the target URL into a new window.</p>

<div class="wp_codebox"><table><tr id="p3585"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p358code5"><pre class="html" style="font-family:monospace;">&nbsp;
&lt;div onclick=&quot;window.open('http://www.brightcherry.co.uk/');&quot;&gt;
&nbsp;
&lt;/div&gt;</pre></td></tr></table></div>

<h4>Open in same window</h4>
<p>Here&#8217;s how to make a div into a clickable link that will open the target URL into the same window.</p>

<div class="wp_codebox"><table><tr id="p3586"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p358code6"><pre class="html" style="font-family:monospace;">&nbsp;
&lt;div onclick=&quot;window.location = 'http://www.brightcherry.co.uk/';&quot;&gt;
&nbsp;
&lt;/div&gt;</pre></td></tr></table></div>

<h4>Notes</h4>
<p>The links CAN be relative to the domain, they don&#8217;t just work with full URLs. You can use URLs like &#8220;/dir/index.html&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brightcherry.co.uk/scribbles/javascript-make-div-into-a-clickable-link/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Javascript &#8211; How To Remove The Trailing Hash In A URL</title>
		<link>http://www.brightcherry.co.uk/scribbles/javascript-how-to-remove-the-trailing-hash-in-a-url/</link>
		<comments>http://www.brightcherry.co.uk/scribbles/javascript-how-to-remove-the-trailing-hash-in-a-url/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 21:48:15 +0000</pubDate>
		<dc:creator>adm1n</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=222</guid>
		<description><![CDATA[Ok, this is a quick note to myself, because I always seem to forget this code, and I have no idea why, because it&#8217;s so simple. So, the scenario is that when I&#8217;m writing AJAX code, a lot of the times I use a hyperlink to trigger an action. For example, look at the following [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, this is a quick note to myself, because I always seem to forget this code, and I have no idea why, because it&#8217;s so simple.</p>
<p>So, the scenario is that when I&#8217;m writing AJAX code, a lot of the times I use a hyperlink to trigger an action. For example, look at the following code&#8230;</p>

<div class="wp_codebox"><table><tr id="p2229"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p222code9"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;#&quot;</span> <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;open_div&quot;</span><span style="color: #339933;">&gt;</span>Open Div<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;show_content&quot;</span> style<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;display:none&quot;</span><span style="color: #339933;">&gt;</span>Show stuff here....<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.open_div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#show_content'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Ok, so what that code is basically doing is displaying a link, with the anchor text, <b class="pink">Open Div</b>. When the link is clicked, the <b class="pink">show_content</b> div will appear, with the containing content.</p>
<p>But the problem is, if I clicked that link on the Bright<b class="pink">Cherry</b> homepage (assuming the code was there), the URL would change to this&#8230;</p>
<p><img src="http://www.brightcherry.co.uk/images/blogimages/brightcherry_hash.jpg" title="Trailing Hash" alt="Trailing Hash" /></p>
<p>Anyone else experience this? It&#8217;s not actually a problem, but it irritates me because I find it ugly and weird (probably because I&#8217;m very particular).</p>
<h4>The Solution</h4>
<p>The fix ISN&#8217;T to simply remove the hash (#) from the A TAG, because then the code won&#8217;t work.</p>
<p>To stop the trailing hash from the URL, you just need to do the following&#8230;</p>

<div class="wp_codebox"><table><tr id="p22210"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p222code10"><pre class="html" style="font-family:monospace;">// replace the hash with the following
&lt;a href=&quot;javascript:void(0);&quot; class=&quot;open_div&quot;&gt;Open Div&lt;/a&gt;</pre></td></tr></table></div>

<p>Ahhh, that&#8217;s better.</p>
<p>Out of curiosity, has this problem actually bothered anyone else?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brightcherry.co.uk/scribbles/javascript-how-to-remove-the-trailing-hash-in-a-url/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HTML Form Effect- Remove Default Value On Focus</title>
		<link>http://www.brightcherry.co.uk/scribbles/html-form-effect-remove-default-value-on-focus/</link>
		<comments>http://www.brightcherry.co.uk/scribbles/html-form-effect-remove-default-value-on-focus/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 10:33:11 +0000</pubDate>
		<dc:creator>adm1n</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=108</guid>
		<description><![CDATA[This Javascript form effect basically removes the default value (e.g Your Name) when the input field is on focus. If nothing is entered, and focus is taken away from the input field, the value is displayed again. It&#8217;s a pretty cool effect, which I&#8217;m always using on a lot of projects. Here&#8217;s an example (click [...]]]></description>
			<content:encoded><![CDATA[<p>This Javascript form effect basically removes the default value (e.g Your Name) when the input field is on focus. If nothing is entered, and focus is taken away from the input field, the value is displayed again. </p>
<p>It&#8217;s a pretty cool effect, which I&#8217;m always using on a lot of projects. Here&#8217;s an example (click in the input field, and then click outside the input field):</p>
<form>
<input type="text" value="Your Name" name="name" onblur="if (this.value == '') {this.value = 'Your Name';}"  onfocus="if (this.value == 'Your Name') {this.value = '';}" />
</form>

<div class="wp_codebox"><table><tr id="p10812"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p108code12"><pre class="html" style="font-family:monospace;">&lt;form&gt;
&lt;input type=&quot;text&quot; value=&quot;Your Name&quot; name=&quot;name&quot; onblur=&quot;if (this.value == '') {this.value = 'Your Name';}&quot;  onfocus=&quot;if (this.value == 'Your Name') {this.value = '';}&quot; /&gt;
&lt;/form&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.brightcherry.co.uk/scribbles/html-form-effect-remove-default-value-on-focus/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

