Please help me how to get host name using html and javascript.

Please help me how to get host name using html and javascript.

Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Prasad RaveendranPosted May 31, 2023, 6:32 PM
HTML File
Javascript file
In this example, we have an HTML page with an
heading and a
paragraph element. The JavaScript code listens for the DOMContentLoaded event to ensure the HTML has finished loading before attempting to access and modify the elements.
The window.location.hostname retrieves the hostname, and document.getElementById('hostname') selects the paragraph element with the id "hostname". Then, we update the text content of the paragraph element using textContent to display the hostname.
Rolando PunoPosted Jun 1, 2023, 3:54 AM
Hello Prasad..

Thanks for your quick reply..by the way im trying to used your code below then i foud out the return is localhost. i want ot get like this: DW00262236
Thank you aonce again
Aravind GovindarajPosted May 31, 2023, 2:39 PM
Please find the sample snippet
Rajkiran SwainPosted May 31, 2023, 11:31 AM