重定向到在文本框中输入的网址

时间:2019-07-16 22:47:17

标签: javascript html variables

当单击“取消阻止”时,我希望它重定向到在文本框中输入的网址。

............................................... ............................

<center>
</font>
  <input size="40" onkeypress="return searchKeyPress(event);" name="getId" type="text" id="getId" style="background-color: black;
  border: 2px;
  border-style: double;
  border-color: white;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  font-weight: bold;
  margin: 4px 2px;
  cursor:;" placeholder="Enter website URL here" />

<button style="background-color: black;
  border: 2px;
  border-style: solid;
  border-color: white;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  font-weight: bold;
  margin: 4px 2px;
  cursor: pointer;"id="btnUnblock" onclick="createLink()">Unblock</button>


</center>

1 个答案:

答案 0 :(得分:0)

尝试一下:

function createLink()
{
    var value_input = document.getElementById('getId').value;

    window.location.href = value_input;
}