Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何为来自浏览器的每个URL请求附加GET参数?_Html_Google Chrome_Firefox_Browser - Fatal编程技术网

Html 如何为来自浏览器的每个URL请求附加GET参数?

Html 如何为来自浏览器的每个URL请求附加GET参数?,html,google-chrome,firefox,browser,Html,Google Chrome,Firefox,Browser,对于测试,我需要为网页中的每个URL引用追加“?testing=true”。 例如,假设网页有一个图像“localhost/image/logo.png”,我需要将它转换为“localhost/image/logo.png?testing=true”,然后加载到浏览器上 我在firefox上尝试了几个插件,它允许在提交时附加/修改URL,但我的要求是在加载时更改URL Firefox Greasemonkey扩展可能会取得一些成功。您可以使用如下脚本: var parameter = '?tes

对于测试,我需要为网页中的每个URL引用追加“?testing=true”。 例如,假设网页有一个图像“localhost/image/logo.png”,我需要将它转换为“localhost/image/logo.png?testing=true”,然后加载到浏览器上


我在firefox上尝试了几个插件,它允许在提交时附加/修改URL,但我的要求是在加载时更改URL

Firefox Greasemonkey扩展可能会取得一些成功。您可以使用如下脚本:

var parameter = '?testing=true'
for (var x = 0; x < document.images.length; x++) {
    image = docuent.images[x];
    image.src = image.src + parameter;
    console.log(image.src);
}
for (x = 0; x < document.getElementsByTagName("link").length; x++) {
    document.getElementsByTagName("link")[x].href = document.getElementsByTagName("link")[x].href + parameter;
}
var参数='?测试=真'
对于(var x=0;x
它用附加了“?testing=true”的相同文件替换所有嵌入的图像和样式表。但是,在此之前仍有对原始图像的请求


另一种选择是使用本地代理(如Charles)进行URL重写

“加载时更改URL”是什么意思?为什么要这样做?我有本地服务器配置来阻止除测试服务器之外的所有点击。但是如果它的url有“?testing=true”,它不会阻止任何url。我无法更改任何服务器设置或操作系统设置。我唯一能控制的就是如何加载URL。如果我加载“”,它将被阻止,如果我加载“”,它将打开。问题是,index.html在个人便笺上有图像引用(将被阻止),我觉得很奇怪,您无法更改localhost上的服务器配置,但无论如何。。。知道你最终想要实现什么也有助于回答你的问题。太好了!。。。它适用于图像。但是它无法加载CSS(localhost/CSS/test.CSS)。是否有任何方法也可以为任何外部引用URl追加参数?