[英]How to pass file name with Url in location.replace() method
我想使用任何重定向页面方法将文件名作为实例传递给url。
<script> function my function() { var x = document.getElementById("demo"); location.replace("localhost:57168/Hoopweb_Viwer.aspx?scs=" +x); } </script>
您可以像在代码中那样,使用window.location.replace
创建模拟重定向,以执行类似的操作。 请注意,协议和域名之后,URL中保留的字符均经过URL编码以避免错误。
我在您的网址中添加了http
,但是您可以将其更改为适当的协议:
<script>
window.addEventListener("DOMContentLoaded", function() {
var x = document.getElementById("demo").value;
x = encodeURI("http://localhost:57168/Hoopweb_Viwer.aspx?scs=" +x);
location.replace(x);
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.