Joined January 2013
·

KS Chan

Hong Kong
·
·
·

Posted to No referer after redirect (Solved) over 1 year ago

Pure JS redirect.

var redirect = function(url) {
  var dom = window.document.createElement('form');

  var parts = url.split('?');
  var url_ = parts[0], params = parts[1] || '';
  var paramlist = params.split('&');

  dom.setAttribute('method', 'get');
  dom.setAttribute('action', url_);
  dom.style.display = 'none';
  dom.style.visibility = 'hidden';

  var e, kv, k, v;
  for (var i = 0; i < paramlist.length; ++i) {
    kv = paramlist[i].split('=');
    k = kv[0];
    v = kv[1];
    e = window.document.createElement('input');

    e.setAttribute('type', 'hidden');
    e.setAttribute('name', decodeURIComponent(k));
    e.setAttribute('value', decodeURIComponent(v));

    dom.appendChild(e);
  }

  window.document.body.appendChild(dom);
  dom.submit();
}
Achievements
95 Karma
19,756 Total ProTip Views