【发布时间】:2021-03-11 04:58:01
【问题描述】:
我有一个带有 CPanel 的域名。我试图创建一个搜索功能,其中 javascript 字符串将与输入 HTML 标记连接,该输入 HTML 标记使用document.getElementById() 存储在变量中。还有一个带有onlick事件的按钮<button id="btn-js" onclick="location.href=text_2">Search</button>
其中 text_2 是网站 URL 字符串和输入 ID 的组合。但是当我运行它时,它会转到我的网站 URL,但在错误页面上。我尝试在 onclick 事件之后添加它,但它不起作用。
完整代码:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta name="author" content="PoopyPooper">
<link rel="stylesheet" href="index.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="icon" href="http://img.asdfghjklzxcvbnm.ml/icons/mainIcon.png">
<meta charset="utf-8">
<meta name="description" content="The place where we store images, icons and many more media for easy use.">
<title>The place where we add media!!</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
var search_feature_text1 = 'http://media.asdfghjklzxcvbnm.ml/';
var lol = document.getElementById("id") //LOL
var text_2 = search_feature_text1+lol;
</script>
</head>
<body>
<p class="head">MEDIA!!</p><br><br><br>
<p class="body-1">Type the url on your web or just type in the image directory(All the text with slashes (if there
are) After media.asdfghjklzxcvbnm.ml/)
here: <br></p>
<p class="content-change">http://media.asddfghjklzxcvbnm.ml/<input type="text" id="id" placeholder="Your directory here">
<button id="btn-js" onclick="location.href=text_2">Search</button></p>
</body>
</html>
【问题讨论】:
标签: javascript html search