bookmarklet将参数添加到url并重新提交?

Chr*_*now 3 javascript bookmarklet

书签是否可以实现以下功能?

  1. 向URL添加其他参数(include_docs = true)
  2. 重新提交URL

我有这个但它在firefox上无声地失败了.我没有尝试过其他浏览器:

javascript:(

   function()
   {
      key = encodeURI('include_docs'); value = encodeURI('true');

      var kvp = document.location.search.substr(1).split('&');

      var i=kvp.length; var x; while(i--) 
      {
        x = kvp[i].split('=');

        if (x[0]==key)
        {
            x[1] = value;
            kvp[i] = x.join('=');
            break;
        }
      }
      if(i<0) {kvp[kvp.length] = [key,value].join('=');}

      //this will reload the page, it's likely better to store this until finished
      document.location.search = kvp.join('&'); 
  }()
);
Run Code Online (Sandbox Code Playgroud)

Cer*_*rus 6

不需要过于复杂的东西;-)

document.location += '&include_docs=true';
Run Code Online (Sandbox Code Playgroud)

这应该够了吧.以书签形式:

javascript:(function(){document.location+='&include_docs=true'}());
Run Code Online (Sandbox Code Playgroud)