用Javascript&中的破折号“ - ”替换空格Vite的HTML

时间:2018-05-20 09:49:32

标签: javascript html redirect

我有一个名为Vite (Flash Engine)的网站,它有一个文本框,您可以在其中键入内容并将其带到网站。 示例:输入“Google”,它会将您带到vitemulti.weebly.com/google,然后转到https://www.google.com

短划线会在网址中放置一个%20 ,但不能使用代码& Weebly。

这个网站上有类似的问题似乎不起作用。

function CheckPassword() {
  var input=document.type.input.value;
  input = input.replace(/\s/g , "-");
  location.href = input+'/';
}
<form method="post" action="ingen_javascript.htm" 
  onsubmit="CheckPassword();return false;" name="type">
<pre>
<input type="text" placeholder="Type in a website" name="input" list="autocomplete" onkeyup="document.getElementById('identifier').value=this.value.replace(/\s/g,'-').toLowerCase();" autofocus>


</pre>
<input type="submit" value="Vite" 
  onclick="CheckPassword();return false;" style="height: 0px; width: 0px; border: none; padding: 0px;" hidefocus="true" onclick="move()">
</form>

是否可以在script添加一些用空格替换空格的内容?

1 个答案:

答案 0 :(得分:1)

<form method="post" action="ingen_javascript.htm" 
  onsubmit="CheckPassword();return false;" name="type">
<pre>
<input type="text" placeholder="Type in a website" name="input" list="autocomplete" onkeyup="document.getElementsByName('input')[0].value=this.value.replace(/\s/g,'-').toLowerCase();" autofocus>


</pre>
<input type="submit" value="Vite" 
  onclick="CheckPassword();return false;" style="height: 0px; width: 0px; border: none; padding: 0px;" hidefocus="true" onclick="move()">
</form>

<script type="text/javascript>
function CheckPassword() {
  var input=document.getElementsByName('input')[0].value;
  input = input.replace(/\s/g , "-");
  console.log(input);
  location.href = input+'/';
}
</script>