
Untitled
By: a guest on
Apr 25th, 2012 | syntax:
None | size: 1.13 KB | hits: 14 | expires: Never
.split() not working as expected in IE8
var p = 'http://sagensundesign.com?height=400&width=300';
/* Get Height */
var h = p.split(/height=([0-9]+)/);
h = h[1];
if (!h) {h = 500};
alert(h);
/* Get Width */
var w = p.split(/width=([0-9]+)/);
w = w[1];
if (!w) {w = 800};
alert(w);
var h = p.match(/height=([0-9]+)/)[1];
/* Get Height */
var h = p.match(/height=([0-9]+)/);
h = h[1];
if (!h) {h = 500};
alert(h);
/* Get Width */
var w = p.match(/width=([0-9]+)/);
w = w[1];
if (!w) {w = 800};
alert(w);
var p = 'http://sagensundesign.com?height=400&width=300';
var siz=p.match(/((height|width)=)(d+)/g);
alert(siz)
/* returned value: (Array)
height=400, width=300
*/
var get = function (name, url) { // Retrieves a specified HTTP GET parameter. Returns null if not found.
url = (typeof (url) === "undefined" ? window.location.href : url);
var regex = new RegExp("[?&]" + name + "=([^&#]*)");
var results = regex.exec(url);
var output = (results ? results[1] : null);
return output;
};
var url = 'http://sagensundesign.com?height=400&width=300';
var h = get("height",url);
var w = get("width",url);