<?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>yesJames.com &#187; programming</title>
	<atom:link href="http://www.yesjames.com/index.php/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yesjames.com</link>
	<description>ahuh... sure... what ever you say...</description>
	<lastBuildDate>Fri, 13 Nov 2009 02:59:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Delphi: Declaring and initialising constant arrays</title>
		<link>http://www.yesjames.com/index.php/2009/02/delphi-declaring-and-initialising-constant-arrays/</link>
		<comments>http://www.yesjames.com/index.php/2009/02/delphi-declaring-and-initialising-constant-arrays/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 03:54:58 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.yesjames.com/?p=141</guid>
		<description><![CDATA[In Delphi, arrays are, put simply, a list of values contained within a common variable, that are accessible by their index within that list.
But what if you don&#8217;t want your list of values to be able to be altered at run-time? You need them to be contained in a constant rather than a variable.
Example: to [...]]]></description>
			<content:encoded><![CDATA[<p><script src="http://www.yesjames.com/wp-content/themes/yesjames_blue/sh/shBrushDelphi.js" type="text/javascript"></script>In Delphi, arrays are, put simply, a list of values contained within a common variable, that are accessible by their index within that list.</p>
<p>But what if you don&#8217;t want your list of values to be able to be altered at run-time? You need them to be contained in a constant rather than a variable.</p>
<p><strong>Example:</strong> to declare an array of abbreviated week names:</p>
<pre name="code" class="delphi">
const
  Days: Array[0..6] of String = (
      'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
  );
</pre>
<p>You could then access each name by the index of the day of the week within the <strong>Days</strong> constant.</p>
<pre name="code" class="delphi">
i := DayOfWeek(Date); //returns an integer 0-6
ShowMessage('Today is  ' + Days[i]);
</pre>
<p>Another common use for constant arrays is to describe the values in an ENUM type:</p>
<pre name="code" class="delphi">
type
  TStatusCodes = [
    scUnknown, scActive, scPending,
    scDisabled, scSuspended
  ];
const
  StatusString = Array[TStatusCodes] of String = (
    'Unknown', 'Active', 'Pending',
    'Disabled', 'Suspended'
  );
</pre>
<p>Then, the description string for each status code becomes available via the ordinal value of the status code itself:</p>
<pre name="code" class="delphi">
ShowMessage('Your account is '+ StatusString[scActive]);
</pre>
<p>Would show a message box with the text &#8220;<em>Your account is Active</em>&#8220;. Of course in the real world, the status code enumeration value would come from a user object or some such similar method (like &#8220;<em>function getAccountStatus(): TStatusCode;</em>&#8221; perhaps).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yesjames.com/index.php/2009/02/delphi-declaring-and-initialising-constant-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox compatible xPath functions in JavaScript</title>
		<link>http://www.yesjames.com/index.php/2008/11/firefox-compatible-xpath-functions-in-javascript/</link>
		<comments>http://www.yesjames.com/index.php/2008/11/firefox-compatible-xpath-functions-in-javascript/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 01:41:27 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XPath]]></category>

		<guid isPermaLink="false">http://www.yesjames.com/?p=74</guid>
		<description><![CDATA[There are a lot of quirks between different browsers, in particular though are the differences in the way each browser handles the DOM in JavaScript.
Internet Explorer, for the most part, implements MSXml 4.0 or higher. However that&#8217;s (obviously) a Microsoft technology, and the standard implementation doesn&#8217;t support XPath in the DOM.
In particular the selectNodes() and [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript" language="javascript" src="http://www.yesjames.com/wp-content/themes/yesjames_blue/sh/shBrushXml.js"></script>There are a lot of quirks between different browsers, in particular though are the differences in the way each browser handles the DOM in JavaScript.</p>
<p>Internet Explorer, for the most part, implements MSXml 4.0 or higher. However that&#8217;s (obviously) a Microsoft technology, and the standard implementation doesn&#8217;t support XPath in the DOM.</p>
<p>In particular the <strong>selectNodes()</strong> and <strong>selectSingleNode()</strong> functions are of particular use when manipulating XML or the DOM. Using these functions you can parse an XPath expression and get a nodelist of elements in your DOM that match the expression.</p>
<p><span id="more-74"></span></p>
<p>The code below adds basic XPath parsing functionality to the DOM in Mozilla. (Thanks to km0ti0n)</p>
<pre name="code" class="javascript">
// mozXPath - http://km0.la/js/mozXPath/
// km0ti0n@gmail.com
// Code licensed under Creative Commons Attribution-ShareAlike License
// http://creativecommons.org/licenses/by-sa/2.5/
if (document.implementation.hasFeature("XPath", "3.0")) {
	if ( typeof XMLDocument == "undefined" ) {
		XMLDocument = Document;
	}
	XMLDocument.prototype.selectNodes = function(cXPathString, xNode) {
		if ( !xNode ) { xNode = this; }
		var oNSResolver = this.createNSResolver(this.documentElement);
		var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
		var aResult = [];
		for ( var i = 0; i < aItems.snapshotLength; i++) {
			aResult[i] =  aItems.snapshotItem(i);
		}
		return aResult;
	}
	XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode) {
		if( !xNode ) { xNode = this; }
		var xItems = this.selectNodes(cXPathString, xNode);
		if ( xItems.length > 0 ) { return xItems[0]; }
		else { return null; }
	}

	Element.prototype.selectNodes = function(cXPathString) {
		if (this.ownerDocument.selectNodes) {
			return this.ownerDocument.selectNodes(cXPathString, this);
		} else { throw "For XML Elements Only"; }
	}

	Element.prototype.selectSingleNode = function(cXPathString) {
		if (this.ownerDocument.selectSingleNode) {
			return this.ownerDocument.selectSingleNode(cXPathString, this);
		} else { throw "For XML Elements Only"; }
	}
}
</pre>
<p>It appears that Opera doesn&#8217;t have the XMLDocument object type, so, when using the XmlHttpRequest object the <em>responseXML</em> is in fact a <em>Document</em> object.</p>
<p>To get around this fact, we can use:</p>
<pre name="code" class="javascript">
if ( typeof XMLDocument == "undefined" ) {
    XMLDocument = Document;
}
</pre>
<p>To use these new features, in either IE or Firefox, you can now simple call the functions as a method of the elements themselves&#8230; e.g.:</p>
<p>On the following XML Document:</p>
<pre name="code" class="xml">
<MainNode>
    <SubNode id="1" enabled="true">
      <ContentNode>Some Content</ContentNode>
    </SubNode>
    <SubNode id="2" enabled="true">
      <ContentNode>Some Content</ContentNode>
    </SubNode>
    <SubNode id="3" enabled="false">
      <ContentNode>Some Content</ContentNode>
    </SubNode>
</MainNode>
</pre>
<p>For the XML sample above, you can use the following XPath to select all <em>ContentNode</em>&#8217;s with their <em>enabled</em> attribute set to <em>&#8220;true&#8221;</em>:<br />
<code>//subnode[@enabled='true']/contentnode</code></p>
<p>So you would retrieve your XML Node List by executing the following JavaScript function:</p>
<pre name="code" class="javascript">
//assume the variable xDOM is an XmlDocument object
//...that has been pre-loaded with the example XML
var nodeList = xDOM.selectNodes('//subnode[@enabled='true']/contentnode');
for each (var xNode in nodeList) {
    //do some operation...
}
</pre>
<p>This would perform some operation on each <em>contentnode</em> which is inside a <em>subnode</em> with it&#8217;s <em>enabled</em> property set to <em>true</em>.</p>
<p><em><strong>NOTE:</strong> Be sure to double check your syntax, spelling and remember XML/XPath is CaseSensitive.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.yesjames.com/index.php/2008/11/firefox-compatible-xpath-functions-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>howto: Format numbers in JavaScript</title>
		<link>http://www.yesjames.com/index.php/2008/11/howto-format-numbers-in-javascript/</link>
		<comments>http://www.yesjames.com/index.php/2008/11/howto-format-numbers-in-javascript/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 23:17:32 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[web programming]]></category>

		<guid isPermaLink="false">http://www.yesjames.com/?p=41</guid>
		<description><![CDATA[Formatting Numbers
Numeric formatting in JavaScript can be very tedious. From handling non-numeric characters, to multiple-currency symbols, to alternate negative display methods. The functions below should be valuable in assisting to format numbers and currencies of all types.

To do complete formatting of a number, the following function formatNumber(), takes several parameters specifying the properties of the [...]]]></description>
			<content:encoded><![CDATA[<h3>Formatting Numbers</h3>
<p>Numeric formatting in JavaScript can be very tedious. From handling non-numeric characters, to multiple-currency symbols, to alternate negative display methods. The functions below should be valuable in assisting to format numbers and currencies of all types.</p>
<p><span id="more-41"></span></p>
<p>To do complete formatting of a number, the following function <b>formatNumber()</b>, takes several parameters specifying the properties of the output.</p>
<pre name="code" class="javascript">
/* formatNumber: PARAMETERS...
num: the decimal number to convert (must be numeric)
dec: number of resulting decimal places to keep
thou: the character to use for thousands separator
pnt: the character to use for decimal point
curr1: Preceding Currency Symbol
curr2: Trailing Currency symbol
n1: Preceding Negative character
n2: Trailing Negative character
*/
function formatNumber(num, dec, thou, pnt, curr1, curr2, n1, n2) {
	var x = Math.round(num * Math.pow(10,dec));
	if (x >= 0) n1 = n2 = '';
	var y = (''+ Math.abs(x)).split('');
	var z = y.length - dec;
	if (z<0) z--;
	for (var i = z; i < 0; i++) y.unshift('0');
	if (z<0) z = 1;
	y.splice(z, 0, pnt);
	if (y[0] == pnt) y.unshift('0');
	while (z > 3) { z-=3; y.splice(z,0,thou); }
	var r = curr1 + n1 + y.join('') + n2 + curr2;
	return r;
}
</pre>
<p>To use this function, simply call the function with the parameters you require.<br />
e.g. To display a currency (western such as USD or AUD):</p>
<pre name="code" class="javascript">
var cur = formatNumber(1257.45, 2, ',', '.', '$', '', '-', '');
alert(cur);
</pre>
<p>will output: <b>$1,257.45</b></p>
<p>Alternatively, you may decide to use a helper function that defaults most of these values for you. For example:</p>
<pre name="code" class="javascript">
function formatCurrency(num) {
  return formatNumber(num, 2, ',', '.', '$', '', '-', '');
}
</pre>
<p>The thousandsFormat() function takes any decimal number, negative or positive, and formats it by adding commas every three digits. This makes the number more readable for your site visitors:</p>
<pre name="code" class="javascript">
// This function formats numbers by adding commas
function thousandsFormat(nStr) {
  nStr += '';
  x = nStr.split('.');
  x1 = x[0];
  x2 = x.length &gt; 1 ? '.' + x[1] : '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x1))
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
  return x1 + x2;
}
</pre>
<h2>Strip Non-Numeric Characters From a String</h2>
<p>The stripNonNumeric() function strips any non-numeric characters from a string leaving you with a valid decimal number. This function considers the minus sign (hyphen) and the period to be numeric and will not strip them unless the minus sign is not at the beginning of the number or there is more than one period:</p>
<pre name="code" class="javascript">
// This function removes non-numeric characters
function stripNonNumeric(str) {
  str += '';
  var rgx = /^\d|\.|-$/;
  var out = '';
  for (var i = 0; i < str.length; i++) {
    if (rgx.test(str.charAt(i))) {
      if (!((str.charAt(i)=='.' &#038;&#038; out.indexOf('.')!=-1)
        || (str.charAt(i)=='-' &#038;&#038;  out.length!=0))) {
        out += str.charAt(i);
      }
    }
  }
  return out;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yesjames.com/index.php/2008/11/howto-format-numbers-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Minimising child forms in an SDI application</title>
		<link>http://www.yesjames.com/index.php/2008/11/delphi-minimising-child-forms-in-an-sdi-application/</link>
		<comments>http://www.yesjames.com/index.php/2008/11/delphi-minimising-child-forms-in-an-sdi-application/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 22:37:10 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[SDI]]></category>
		<category><![CDATA[Win32]]></category>

		<guid isPermaLink="false">http://www.yesjames.com/?p=45</guid>
		<description><![CDATA[In an SDI application (Single Document Interface), the main form acs as the &#8220;container&#8221; for the entire application. This means that child forms, are exactly that &#8211; children of the application. The long and short of which, means that when you minimise the main form of the application, all forms are hidden. In addition to [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript" language="javascript" src="http://www.yesjames.com/wp-content/themes/yesjames_blue/sh/shBrushDelphi.js"></script>In an SDI application (Single Document Interface), the main form acs as the &#8220;container&#8221; for the entire application. This means that child forms, are exactly that &#8211; children of the application. The long and short of which, means that when you minimise the main form of the application, all forms are hidden. In addition to which, when you minimise a child form of the application, it doesn&#8217;t minimise to the task bar, instead it minimises to the application desktop. This also has the side effect that only the main application form itself has a task bar button.</p>
<p>So, How do I change this behaviour?</p>
<p><span id="more-45"></span></p>
<p>For one reason or another, you may decide that you want to let each child form in an application you create have it&#8217;s own Task Bar button, and as a result, complete control over it&#8217;s visibility when the application&#8217;s main form is minimized/restored. Ordinarily, the first form created in your application is the <i>Main Form</i>. It is the parent of all other forms that will be created in your application, and as such, when the main form closes, the application terminates. In addition, when the main form is minimised, all child forms are also minimized as the application is hidden. Only the main form in this case has a button on the task bar.</p>
<h3>So, you don&#8217;t really want your child forms to be hidden when you minimise the main form of the application&#8230;</h3>
<p>Well, you need to do two things. Both can be done inside the <b>CreateParams()</b> method of your form. SO you&#8217;ll need to override this procedure.<br/><br />
Firstly, you&#8217;ll need to change the style parameters of the form when it is created. More specifically, you need to override the  and manually set the <b>ExStyle</b> parameter. Secondly, you&#8217;ll need to change the parent of the form form the applications main form to something else &#8211; usually the Windows Desktop.</p>
<p>Firstly, you need to add the style <b><i>WS_EX_APPWINDOW</i></b> to the style of the window being created. You can do this by <b><i>or</i></b>ing this constant with the <i>ExStyle</i> paramter as such:</p>
<pre name="code" class="delphi">
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
</pre>
<p>So, the code would look like this:</p>
<pre name="code" class="delphi">
interface

type
TChildForm = class(TForm)
  ...
  protected
  procedure CreateParams(var Params: TCreateParams); override;
    ...

implementation

  procedure TChildForm.CreateParams(var Params: TCreateParams);
  begin
    inherited;
    Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
    Params.WndParent := GetDesktopWindow;
  end;
</pre>
<p>References:</p>
<p>http://delphi.about.com/od/formsdialogs/a/child_forms.htm</p>
<p>http://delphi.about.com/od/formsdialogs/l/aa073101a.htm</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yesjames.com/index.php/2008/11/delphi-minimising-child-forms-in-an-sdi-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaScript Trim() function</title>
		<link>http://www.yesjames.com/index.php/2008/03/javascript-trim-function/</link>
		<comments>http://www.yesjames.com/index.php/2008/03/javascript-trim-function/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 05:25:14 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[trim]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.yesjames.com/index.php/2008/03/20/javascript-trim-function/</guid>
		<description><![CDATA[Trim(), is one function that we all use almost every day in most languages, whether it&#8217;s a core function of the language you&#8217;re using or a member (or prototype in JavaScript) function of the String object itself (as in C#), it&#8217;s invaluable for developers.
Unfortunately JavaScript doesn&#8217;t have this sort of thing built in, so here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Trim(), is one function that we all use almost every day in most languages, whether it&#8217;s a core function of the language you&#8217;re using or a member (or prototype in JavaScript) function of the String object itself (as in C#), it&#8217;s invaluable for developers.</p>
<p>Unfortunately JavaScript doesn&#8217;t have this sort of thing built in, so here&#8217;s how to implement your own <em>trim()</em> functions (as well as ltrim() and rtrim()) in various ways depending on the level of backward compatibility you require.</p>
<p><span id="more-42"></span></p>
<h3>trim() member functions</h3>
<p>Use the code below to make trim a method of all Strings. Ordinarily you would place this code into a global JavaScript file that would be included in all your pages.</p>
<pre name="code" class="javascript">
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}

String.prototype.ltrim = function() {
    return this.replace(/^\s+/,"");
}

String.prototype.rtrim = function() {
    return this.replace(/\s+$/,"");
}
</pre>
<h4>Examples using trim(), ltrim(), and rtrim() prototyped methods</h4>
<pre name="code" class="javascript">
var testString = " hello world ";
alert("#"+ testString.trim() +"#");
alert("#"+ testString.ltrim() +"#");
alert("#"+ testString.rtrim() +"#");
</pre>
<h3>standalone JavaScript functions</h3>
<p>If you&#8217;d prefer to use regular functions to return trimmed strings rather than modifying the String object using prototyping, then try the following code:</p>
<pre name="code" class="javascript">
function trim(value) {
    return value.replace(/^\s+|\s+$/g,"");
}
function ltrim(value) {
    return value.replace(/^\s+/,"");
}
function rtrim(value) {
    return value.replace(/\s+$/,"");
}
</pre>
<h4>Examples using trim(), ltrim(), and rtrim() functions</h4>
<pre name="code" class="javascript">
var testString = " hello world ";
alert("#"+ trim(testString) +"#");
alert("#"+ ltrim(testString) +"#");
alert("#"+ rtrim(testString) +"#");
</pre>
<h3>Compatibility</h3>
<p>The above functions require JavaScript 1.2+ and JScript 3.0+ as they are using Regular Expressions to work their magic. This pretty much covers all modern browsers (v4 and above of IE and opera, and all versions of Firefox).<br />
If you require functions that will be compatible with very old browsers only supporting JavaScript 1.0 or there about, try using the following set of functions. These functions strip the following standard whitespace characters: space, tab, line feed, carriage return, and form feed. The IsWhitespace function checks if a character is whitespace.</p>
<pre name="code" class="javascript">
function ltrim(str) {
    for(var k = 0;
        k &lt; str.length &amp;&amp; isWhitespace(str.charAt(k));
        k++);
    return str.substring(k, str.length);
}
function rtrim(str) {
    for(var j=str.length-1;
        j&gt;=0 &amp;&amp; isWhitespace(str.charAt(j));
        j--);
    return str.substring(0,j+1);
}
function trim(str) {
    return ltrim(rtrim(str));
}
function isWhitespace(charToCheck) {
    var whitespaceChars = " \t\n\r\f";
    return (whitespaceChars.indexOf(charToCheck) != -1);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yesjames.com/index.php/2008/03/javascript-trim-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>howto: GET a URL parameter in JavaScript</title>
		<link>http://www.yesjames.com/index.php/2008/02/howto-get-a-url-parameter-in-javascript/</link>
		<comments>http://www.yesjames.com/index.php/2008/02/howto-get-a-url-parameter-in-javascript/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 09:38:01 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[get parameter]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[url parameter]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.yesjames.com/index.php/2008/02/11/howto-get-a-url-parameter-in-javascript/</guid>
		<description><![CDATA[A useful little piece of JavaScript for retrieving a URL parameter (Query String) from your page. If a requested parameter doesn&#8217;t exist it will return an empty string rather than a NULL object. It will also handle the inclusion of anchor tags in the URL and exclude them from possible results.
e.g. http://www.yesjames.com/test.php?myparam=justatest
calling &#8220;gerURLParam(&#8216;myparam&#8217;) will return [...]]]></description>
			<content:encoded><![CDATA[<p>A useful little piece of JavaScript for retrieving a URL parameter (Query String) from your page. If a requested parameter doesn&#8217;t exist it will return an empty string rather than a NULL object. It will also handle the inclusion of anchor tags in the URL and exclude them from possible results.</p>
<blockquote><p>e.g. http://www.yesjames.com/test.php?myparam=justatest<br />
calling &#8220;gerURLParam(&#8216;myparam&#8217;) will return &#8220;justatest&#8221;</p></blockquote>
<pre name="code" class="javascript">
function getURLParam(name) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var pattern = "[\\?&amp;]"+name+"=([^&amp;#]*)";
  var regex = new RegExp(pattern);
  var aResult = regex.exec(window.location.href);
  if ( aResult == null ) {
    return "";
  } else {
    return aResult[1];
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yesjames.com/index.php/2008/02/howto-get-a-url-parameter-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
