+ 1

How to make this code result open other web?

<html> <head> <title>Page Title</title> <base href="google.com/"> World Search<br/> </head> <body> <input type="text" class="input" placeholder="name world"> <a id="link"><button class="item_clicking" type="button">Go</button></a> <script> var f=document.querySelector(".input"); var g=document.querySelector("#link"); var k=document.querySelector(".item_clicking"); k.addEventListener("click",function(){ g.href=f.value; }); </script> </body> </html> this code result if click go button: myweb.com/google.com/input how to make the result be: otherweb.com/google.com/input ?

18th Jun 2020, 3:27 AM
Ahmad Sofiyurrohman
Ahmad Sofiyurrohman - avatar
1 Antwort
+ 3
href="google.com" define a relative url to your page... you must make it absolute url by prependind to it a protocol (ie: "http://" or "https://" in most of the cases). Anyway, putting html page content in head (World Search<br/>) is a bad practice and should be avoided (and could result in unexpected behaviors) ^^
18th Jun 2020, 9:29 AM
visph
visph - avatar