0

重複の可能性:
jQueryでURLパラメーターを取得する

このURLをブラウザで取得しました

http://docs.google.com?k=account&cs=This%20Site&u=https%3A%2F%2Faccess.dev.google.com

u paramterにhttpまたはhttps://access.dev.google.comがあるかどうかを確認してから、何らかのアクションを実行する必要があります。

4

2 に答える 2

0

になり得る:

var hr = 'http://docs.google.com?k=account&cs=This%20Site&u=http%3A%2F%2Faccess.dev.google.com'; //window.location.href;

var res = hr.match(/u=(http|https)%3A%2F%2Faccess.dev.google.com/g);
if(res != null) alert('ok');
else alert('not found');

jensgram のコメントをご覧ください。/u= は次のようになります: [?&]u=

于 2012-08-02T06:06:11.327 に答える
0

これは素敵な非正規表現バージョンです。

var path = window.location.pathname;
//assuming you want the path for http://docs.google.com?k=account&cs=This%20Site&u=https%3A%2F%2Faccess.dev.google.com


if(path.substring(path.indexOf('u='​)+2, path.indexOf('u=')+7) == 'https') {
    //execute if https, or change to +2, +6 for http
}​​​​​​​​​

それがあなたが探しているものかどうかはわかりませんが、試してみる価値はありました。

于 2012-08-02T06:15:30.353 に答える