.split() not working as expected in IE8

后端 未结 5 757
Happy的楠姐
Happy的楠姐 2021-01-13 03:48

I\'m using the following to extract variables from a URL contained in a variable. It works fine in modern browsers but in IE8 it fails on the first variable but succeeds on

5条回答
  •  孤街浪徒
    2021-01-13 04:40

    Use p.match(regex) instead:

    http://jsfiddle.net/B42tM/3/

    /* 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);
    

提交回复
热议问题