-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
35 lines (33 loc) · 1.24 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Script loading</title>
<link rel='stylesheet' type="text/css" href="main.css">
</head>
<body>
<h1>Hello</h1>
<input type='text' placeholder="Enter the concept..."></input>
<div class='chatWindow'>
</div>
<div class='chatButtonContainer' id='chatButton'><img class='image' src='./25360.png'/></div>
<script type='text/javascript'>
var chatButton = document.getElementById('chatButton');
let fileName = 'main.js';
let url = 'https://javascript.info';
chatButton.addEventListener('click', e => {
let fileRef;
let concept = document.getElementsByTagName('input')[0].value;
if(concept)
url = url+`/search/?query=${concept}&type=article`;
console.log(concept);
if(fileName){
fileRef = document.createElement('script');
fileRef.setAttribute('type','text/javascript');
fileRef.setAttribute('src',fileName)
}
if (typeof fileRef!="undefined")
document.getElementsByTagName("head")[0].appendChild(fileRef);
})
</script>
</body>
</html>