Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.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
将javascript变量传递给url参数_Javascript_Python_Html_Flask_Url - Fatal编程技术网

将javascript变量传递给url参数

将javascript变量传递给url参数,javascript,python,html,flask,url,Javascript,Python,Html,Flask,Url,我想传递javascript字符串变量并在URL上呈现它们 例如,如果我有URL=“xyc.com”。填充变量(a)后,我希望在地址栏中使用URL=“xyc.com/?a=”呈现该变量 我目前正在这个应用程序中使用javascript中的flask和.ajax函数(填充变量的地方)。有人能为我提供一些如何完成这项任务的指导吗?谢谢大家! 如果要在不重新加载页面的情况下替换URL window.history.replaceState(null, null, new_url); 如果要使用新UR

我想传递javascript字符串变量并在URL上呈现它们

例如,如果我有URL=“xyc.com”。填充变量(a)后,我希望在地址栏中使用URL=“xyc.com/?a=”呈现该变量


我目前正在这个应用程序中使用javascript中的flask和.ajax函数(填充变量的地方)。有人能为我提供一些如何完成这项任务的指导吗?谢谢大家!

如果要在不重新加载页面的情况下替换URL

window.history.replaceState(null, null, new_url);
如果要使用新URL重新加载页面

window.location.href = new_url

尝试以下方法替换URL:


结束URL
让url=location.href;
setItem(“url”,url);
函数modURL(){
if(typeof(history.pushState)!=“未定义”){
让newURL=localStorage.getItem(“url”)+'?q='+document.getElementById('append').value;
让title=document.getElementById('append').value;
设obj={Title:Title,Url:newURL};
log(“url”,newURL);
pushState(obj,obj.Title,obj.Url);
}否则{
警报(“浏览器不支持HTML5”);
}
}