by Jim
Jan 30, 2007 2:38 PM
This shouldn't be so hard to google. To parse an html page's query string with Javascript, using a regular expression:
// Get the value of one of the arguments in the query string
function getFieldValue(name)
{
var match = (new RegExp('[?&;]' + name + '=([^&;#]*)')).exec(location.search);
return match ? unescape(match[1]) : "";
}
Returns an empty string if the name doesn't match.
by Jim
Jan 25, 2007 7:54 AM
My Vista sidebar gadget stopped working after a reboot, and I quickly discovered that the XMLHttpRequest.status was coming back as 0.
There are several reasons that this can happen - in my case it was a bug compounded with running in the sidebar. The bug was sending empty strings for username and password in the open method:
req.open("GET", "http://rpc.bloglines.com/listsubs", true, username, password);
In a browser (IE7 anyway,) the login fails and a dialog pops up asking for name and password. But the sidebar doesn't ask, and strangely it doesn't fail with a status 401, invalid login. It fails with status 0.