<?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>MaggsWeb:7 &#187; Javascript</title>
	<atom:link href="http://www.maggsweb.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maggsweb.com</link>
	<description>www.maggsweb.com</description>
	<lastBuildDate>Sat, 21 Aug 2010 20:50:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>jQuery show/hide DIV &amp; Image</title>
		<link>http://www.maggsweb.com/javascript/jquery-showhide-div-image/</link>
		<comments>http://www.maggsweb.com/javascript/jquery-showhide-div-image/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 08:31:55 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=715</guid>
		<description><![CDATA[Show/Hide areas are common place now all over the web and are an easy way to display large amounts of information that may/may not be useful to all readers. The [+] and [-] images are the key, and changing these must be seamless.. Enter jQuery. ?View Code JAVASCRIPT&#160; $(document).ready(function() { &#160; $('.searchItem').hide(); //initial hide &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Show/Hide areas are common place now all over the web and are an easy way to display large amounts of information that may/may not be useful to all readers.  The [+] and [-] images are the key, and changing these must be seamless..<br />
Enter jQuery.<br />
<span id="more-715"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p715code2'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7152"><td class="code" id="p715code2"><pre class="javascript" style="font-family:monospace;">&nbsp;
    $(document).ready(function() {
&nbsp;
      $('.searchItem').hide();    //initial hide 
&nbsp;
	  $('a#showHideBtn').toggle(
		   function(){ 
				$('.searchItem').show('slow');
				$('#showHideImage').attr('src','../images/hide.gif');
		   }, function() { 
				$('.searchItem').hide('slow');
				$('#showHideImage').attr('src','../images/show.gif');
		   });
&nbsp;
      });</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/javascript/jquery-showhide-div-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display filesizes</title>
		<link>http://www.maggsweb.com/javascript/display-filesizes/</link>
		<comments>http://www.maggsweb.com/javascript/display-filesizes/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 08:26:40 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=767</guid>
		<description><![CDATA[Ever clicked a link only to find out that the image/download was massive and you wished you hadn&#8217;t? Wouldn&#8217;t it have been nice to have an idea of the file-size when hovering over the link? ?View Code JAVASCRIPT&#160; function byteConvert(num) { var result = 0; var unit = &#34;&#34;; &#160; // Set unit variables for [...]]]></description>
			<content:encoded><![CDATA[<p>Ever clicked a link only to find out that the image/download was massive and you wished you hadn&#8217;t?  Wouldn&#8217;t it have been nice to have an idea of the file-size when hovering over the link?<br />
<span id="more-767"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p767code4'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7674"><td class="code" id="p767code4"><pre class="javascript" style="font-family:monospace;">&nbsp;
function byteConvert(num) {
	var result = 0;
	var unit = &quot;&quot;;
&nbsp;
	// Set unit variables for convenience
	var bytes = 1;
	var kb = 1024;
	var mb = 1048576;
	var gb = 1073741824;
&nbsp;
	// Check for non-numeric or negative num argument
	if (not isNumeric(num) OR num LT 0)
		return &quot;Invalid size argument&quot;;
&nbsp;
	// Check to see if unit was passed in, and if it is valid
	if ((ArrayLen(Arguments) GT 1)
		AND (&quot;bytes,KB,MB,GB&quot; contains Arguments[2]))
	{
		unit = Arguments[2];
	// If not, set unit depending on the size of num
	} else {
		  if      (num lt kb) {	unit =&quot;bytes&quot;;
		} else if (num lt mb) {	unit =&quot;KB&quot;;
		} else if (num lt gb) {	unit =&quot;MB&quot;;
		} else                {	unit =&quot;GB&quot;;
		}		
	}
&nbsp;
	// Find the result by dividing num by the number represented by the unit
	result = num / Evaluate(unit);
&nbsp;
	// Format the result
	if (result lt 10)
	{
		result = NumberFormat(Round(result * 100) / 100,&quot;0.00&quot;);
	} else if (result lt 100) {
		result = NumberFormat(Round(result * 10) / 10,&quot;90.0&quot;);
	} else {
		result = Round(result);
	}
	// Concatenate result and unit together for the return value
	return (result &amp; &quot; &quot; &amp; unit);
}</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/javascript/display-filesizes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Catching a keyPress..</title>
		<link>http://www.maggsweb.com/html/catching-a-keypress/</link>
		<comments>http://www.maggsweb.com/html/catching-a-keypress/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 10:51:33 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://tech.maggsweb.co.uk/?p=291</guid>
		<description><![CDATA[&#8230;like &#8216;Enter&#8217; for instance. ?View Code JAVASCRIPTfunction handleEnter (field, event) { var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; if (keyCode == 13) { //do something, eg: submitForm(); } else { return true; } }]]></description>
			<content:encoded><![CDATA[<p>&#8230;like &#8216;Enter&#8217; for instance.</p>
<p><span id="more-291"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p291code6'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2916"><td class="code" id="p291code6"><pre class="javascript" style="font-family:monospace;">function handleEnter (field, event) {
  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  if (keyCode == 13) { 
        //do something, eg:
	submitForm();
  } else {
   return true;
  }
}</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/html/catching-a-keypress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Print a Page, or Print a Section</title>
		<link>http://www.maggsweb.com/html/print-a-page-or-print-a-section/</link>
		<comments>http://www.maggsweb.com/html/print-a-page-or-print-a-section/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 10:08:31 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://tech.maggsweb.co.uk/?p=289</guid>
		<description><![CDATA[This is another functionality that I have been looking or for a while. I haven&#8217;t tried it yet, but intend to add this to my default toolbox! I am sticking it here for now &#8211; and will update this when I have used it. ?View Code JAVASCRIPT&#160; function printPageComponent() { html = '&#60;div id=&#34;print-page&#34;&#62;'; html [...]]]></description>
			<content:encoded><![CDATA[<p>This is another functionality that I have been looking or for a while.  I haven&#8217;t tried it yet, but intend to add this to my default toolbox!  I am sticking it here for now &#8211; and will update this when I have used it.</p>
<p><span id="more-289"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p289code8'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2898"><td class="code" id="p289code8"><pre class="javascript" style="font-family:monospace;">&nbsp;
function printPageComponent() {
  html  = '&lt;div id=&quot;print-page&quot;&gt;';
  html += '  &lt;input class=&quot;button&quot; \n';
  html += '         id=&quot;print-page-button&quot; \n';
  html += '         onclick=&quot;window.print();&quot; \n';
  html += '         onmouseup=&quot;this.blur();&quot; \n';
  html += '         title=&quot;Print the current page.&quot; \n';
  html += '         type=&quot;button&quot; \n';
  html += '         value=&quot;Print this page&quot;';
  html += '   /&gt;';
  html += '&lt;/div&gt;';
  return html;
}
&nbsp;
function printPageLink() {
  html  = &quot;&lt;span id=\&quot;component-box-print-link\&quot; \n&quot;;
  html += &quot;      class=\&quot;button\&quot;\n&quot;;
  html += &quot;      onclick=\&quot;window.print();\&quot;&gt;\n&quot;;
  html += &quot;Print this page&quot;;
  html += &quot;&lt;/span&gt;&quot;;
  return html;
}</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/html/print-a-page-or-print-a-section/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross-browser bookmark link</title>
		<link>http://www.maggsweb.com/html/cross-browser-bookmark-link/</link>
		<comments>http://www.maggsweb.com/html/cross-browser-bookmark-link/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 09:56:56 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://tech.maggsweb.co.uk/?p=284</guid>
		<description><![CDATA[&#8216;Bookmark Me&#8217; is a sort of IE thing and doesn&#8217;t usually work in FireFox, Safari, Chrome, etc.. so as a FireFox user I&#8217;ve never bothered with a bookmark links before. FireFox users know that Ctrl+D is the shortcut for these browsers, and that most &#8216;Bookmark Me&#8217; links just aren&#8217;t work clicking &#8211; as they won&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>&#8216;Bookmark Me&#8217; is a sort of IE thing and doesn&#8217;t usually work in FireFox, Safari, Chrome, etc.. so as a FireFox user I&#8217;ve never bothered with a bookmark links before.<br />
FireFox users know that Ctrl+D is the shortcut for these browsers, and that most &#8216;Bookmark Me&#8217; links just aren&#8217;t work clicking &#8211; as they won&#8217;t work.</p>
<p>And then I found this&#8230;</p>
<p><span id="more-284"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p284code10'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p28410"><td class="code" id="p284code10"><pre class="javascript" style="font-family:monospace;">&nbsp;
function bookmarkIt(){
if(document.all){
   window.external.AddFavorite(location.href,document.title);
   }
else if(window.sidebar){
   window.sidebar.addPanel(document.title,location.href,'');
   }
}</pre></td></tr></table></div>

<p>&#8230;although I haven&#8217;t actually used it yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/html/cross-browser-bookmark-link/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS fixes for IE, using Javascript</title>
		<link>http://www.maggsweb.com/css/css-fixes-for-ie-using-javascript/</link>
		<comments>http://www.maggsweb.com/css/css-fixes-for-ie-using-javascript/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 09:54:16 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://tech.maggsweb.co.uk/?p=217</guid>
		<description><![CDATA[Some CSS effects don&#8217;t work in IE, damn them, so that leaves 2 options. Either forget that you have coded some nice roll-over effects that the majority of people wont see&#8230; Or, add an IE-specific javascript fix. ?View Code CSS&#60;!--&#91;if IE&#93;&#62; &#60;script type=&#34;text/javascript&#34; src=&#34;/content/iehover-fix.js&#34;&#62;&#60;!-- ---&#62;&#60;/script&#62; &#60;!&#91;endif&#93;--&#62;]]></description>
			<content:encoded><![CDATA[<p>Some CSS effects don&#8217;t work in IE, damn them, so that leaves 2 options.</p>
<p>Either forget that you have coded some nice roll-over effects that the majority of people wont see&#8230;</p>
<p>Or, add an IE-specific javascript fix.<br />
<span id="more-217"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p217code12'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p21712"><td class="code" id="p217code12"><pre class="css" style="font-family:monospace;">&lt;!--<span style="color: #00AA00;">&#91;</span>if IE<span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&gt;</span>
&lt;script type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> src<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;/content/iehover-fix.js&quot;</span><span style="color: #00AA00;">&gt;</span>&lt;!-- ---<span style="color: #00AA00;">&gt;</span>&lt;/script<span style="color: #00AA00;">&gt;</span>
&lt;!<span style="color: #00AA00;">&#91;</span>endif<span style="color: #00AA00;">&#93;</span>--<span style="color: #00AA00;">&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/css/css-fixes-for-ie-using-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Search, with no click</title>
		<link>http://www.maggsweb.com/php/search-with-no-click/</link>
		<comments>http://www.maggsweb.com/php/search-with-no-click/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 08:17:12 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://tech.maggsweb.co.uk/?p=188</guid>
		<description><![CDATA[How do you style a search button?  They all look crap to me, and the default browser ones are all different.  So, my solution is to get rid of it.  Gone.  No button.    Heres how&#8230;]]></description>
			<content:encoded><![CDATA[<p>How do you style a search button?  They all look crap to me, and the default browser ones are all different.  So, my solution is to get rid of it.  Gone.  No button.    Heres how&#8230;</p>
<p><span id="more-188"></span></p>
<pre>
<?php $search_text = 'Search MaggsWeb'; ?>
<form id="searchForm" action="search-results.php" method="GET">
<input name="q" type="text" class="inputBox searchBox"
value="<?php echo $search_text; ?>"
onblur="if (this.value == '')  { this.value = '<?php echo $search_text; ?>'; }"
onfocus="if (this.value == '<?php echo $search_text; ?>')  { this.value = ''; }"
/>
<input type="hidden" id="searchsubmit" />
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/search-with-no-click/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open/Close, Show/Hide DIV&#8217;s</title>
		<link>http://www.maggsweb.com/html/openclose-showhide-divs/</link>
		<comments>http://www.maggsweb.com/html/openclose-showhide-divs/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 11:59:44 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.cmaggs.co.uk/html/30</guid>
		<description><![CDATA[This is used more and more to display more info, hidden fields, etc&#8230; It could easily be improved with multiple divs stacked in the same place&#8230; Hmmm&#8230;, now I am getting ideas. ?View Code JAVASCRIPTfunction openCloseDiv( elementId ){ var element = document.getElementById(elementId); if ( element.style.display == 'block' ) { element.style.display = 'none'; } else { [...]]]></description>
			<content:encoded><![CDATA[<p>This is used more and more to display more info, hidden fields, etc&#8230;<br />
It could easily be improved with multiple divs stacked in the same place&#8230;<br />
Hmmm&#8230;, now I am getting ideas.<br />
<span id="more-30"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p30code15'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3015"><td class="code" id="p30code15"><pre class="javascript" style="font-family:monospace;">function openCloseDiv( elementId ){
  var element = document.getElementById(elementId);
  if ( element.style.display == 'block' ) {
    element.style.display = 'none';
  } else {
    element.style.display = 'block';
  }
}</pre></td></tr></table></div>

<p>OK, Thats the function set up.  Store this in javscript.js or something simillar&#8230;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p30code16'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3016"><td class="code" id="p30code16"><pre class="html" style="font-family:monospace;">&lt;span title=&quot;Click here to display info...&quot; onclick=&quot;openCloseDiv( 'DIVNAME' )&quot;&gt;
	Blah Blah....
&lt;/span&gt;
&lt;div id=&quot;DIVNAME&quot; style=&quot;display: none;&quot;&gt;   // or when open, &quot;display: block;&quot;
	---DIV CONTENTS---&lt;/div&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/html/openclose-showhide-divs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
