JS:隐藏Url中的参数

<script type="text/javascript">
function submitForm(url, data)
{
  var eleForm = document.body.appendChild(document.createElement('form'));
  eleForm.action = url;
  for (var property in data)
  {
    var hiddenInput = document.createElement('input');
    hiddenInput.type = 'hidden';
    hiddenInput.name = property;
    hiddenInput.value = data[property];
    eleForm.appendChild(hiddenInput);
  }
  this.eleForm = eleForm;
  if (!submitForm._initialized)
  {
    submitForm.prototype.post = function ()
     {
      this.eleForm.method = 'post';
      this.eleForm.submit();
    };
  submitForm._initialized = true;
  }
}

function Onclick()
{
  //location.href = "/Activity/ActivityInformation?a_id=" + "1"; // Url中会带有参数
  new submitForm('/Activity/ActivityInformation', { a_id: "1" }).post(); // Url中的参数被隐藏
}
</script>
posted @ 2016-11-02 18:37  陈昌鸿  阅读(10713)  评论(0编辑  收藏  举报