bookmarklet在url中添加一个参数并重新提交

bookmarklet to add a parameter to the url and resubmit it?

本文关键字:参数 提交 新提交 一个 url 添加 bookmarklet      更新时间:2023-09-27

使用bookmarklet可以实现以下功能吗?

  1. 在URL中添加一个附加参数(include_docs=true)
  2. 重新提交URL

我有这个,但它在萤火虫上无声地失败了。我还没有尝试过其他浏览器:

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('&'); 
  }()
);

无需使任何事情过于复杂;-)

document.location += '&include_docs=true';

这就行了。以bookmarklet形式:

javascript:(function(){document.location+='&include_docs=true'}());