gpt4 book ai didi

javascript - bookmarklet 添加一个参数到 url 并重新提交它?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:45:54 25 4
gpt4 key购买 nike

小书签可以实现以下功能吗?

  1. 向 URL 添加附加参数 (include_docs=true)
  2. 重新提交网址

我有这个,但它在 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('&');
}()
);

最佳答案

无需将任何事情复杂化;-)

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

这应该可以解决问题。以书签形式:

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

关于javascript - bookmarklet 添加一个参数到 url 并重新提交它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28478198/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com