2013年9月21日土曜日

末尾の文字を取り除く方法

文字列末尾に / があった時に取り除く方法

s = s.replace(/\/$/,'');

// ↑より高速
if ('/' === s.charAt(s.length - 1))
  s.slice(0, -1);


// ES6から
if (s.endsWith('/'))
  s.slice(0, -1);

2013年9月11日水曜日

リファラを消す

a.onclick = function () {

     //remove referer

    this.href = "data:text/html;charset=utf-8," + encodeURIComponent('<script>\x3c!--\ndocument.write(\'<meta http-equiv="refresh" content="0;url=' + this.href + "\">');//--\x3e\x3c/script>")

}