Javascript examples for Browser Object Model:Window alert
Window alert() Method - Alert the hostname of the current URL:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from ww w. java2 s . com console.log(location.hostname); } </script> </body> </html>