正在向提交的URL末尾添加字符串

Adding string to the end of submitted URL?

本文关键字:添加 字符串 URL 提交      更新时间:2023-09-26

我正在组装一个简单的工作工具,用户可以在表单字段中添加一些数据,这允许他们远程访问设备,但我需要它来将他们带到登录页面。

<input type="text" name="prog_site" id="prog_site" value="http://" />
<a href="http://" onclick="this.href=document.getElementById('prog_site').value" target="_blank">Let's go!</a>

以上将它们带到所述设备,但我在添加一个脚本时遇到了问题,然后在提交的信息(这是一个IP地址)之后添加以下内容

/web/guest/en/websys/webArch/authForm.cgi

我一直在寻找方法,但需要尽可能简单吗?

以下是完整的脚本:

    <script>
function open_win() 
{
window.open("");
}
</script>
<style>
body {
background-color: #fff;
}
</style>
<p><img src="logo.gif" /></p>
<p>Hello customer</p>
<p>Welcome to the Activation</p>
<p><a target="_new" href="">Instructions</a></p>

<input type="text" name="prog_site" id="prog_site" value="http://" />
<a href="http://" onclick="this.href=document.getElementById('prog_site').value" target="_blank">Let's go!</a>

可能我误解了这个问题,但出了什么问题

<a href="http://"
    onclick="this.href=(document.getElementById('prog_site').value +
                       '/web/guest/en/websys/webArch/authForm.cgi')"
    target="_blank">Let's go!</a>

这就是您想要实现的目标吗?

<input type="text" name="prog_site" id="prog_site" value="http://" />
<a href="http://" onclick="this.href+=('/web/guest/en/websys/webArch/authForm.cgi?ip=' + document.getElementById('prog_site').value); return true;" target="_blank">Let's go!</a>

你的问题我不清楚。但我认为你想在你的URL中添加一个QueryString。所以您可以简单地使用?符号来添加它。

var URL = "YourURL";
    URL = URL + "?IP=" + "YourString"; 

更新后-

<a href="http://" onclick="this.href=(document.getElementById('prog_site').value +'/web/guest/en/websys/webArch/authForm.cgi')" target="_blank">Let's go!</a>

JSFiddle

<input type="text" name="prog_site" id="prog_site" value="http://" />
<input type="button" value="Let's go!" onclick="window.location.replace('http://web/guest/en/websys/webArch/authForm.cgi?ip='+document.getElementById('prog_site').value); return true;"></input>