html怎么处理文本框输入的内容

求解

我需要一个html页面,这个页面里面有一个输入框,一个提交
我在文本框中输入,https://segmentfault.com/  ,然后点提交的时候 打开的是这个页面http//localhost/y.php?_u=https://segmentfault.com/   

这个要怎么实现,小白求助

阅读 2.9k
2 个回答

试一下这个

<input id="name" type="text">
<button onclick="Submit();">提交</button>

<script>
    let url = 'http://localhost/y.php?_u=';
        
    function Submit () {
        let name = document.getElementById('name'),
            nameValue = name.value
            Url = '';
        Url = url + nameValue;
        
        console.log(Url);
        window.location = Url;
    }
</script>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题