Membership is FREE – with unlimited access to all features, tools, and discussions. Premium accounts get benefits like banner ads and newsletter exposure. ✅ Signature links are now free for all. Share your own thoughts and experience, accounts may be terminated for violations.

Simple Javascript help

Status
Not open for further replies.
Joined
May 23, 2005
Posts
2,036
Reaction score
50
Hiya I have

PHP:
<script>
document.write(window.location.hostname)
</script>

Which would display www.domain.com

but I would like to strip out the www. bit so it only displays domain.com

How would I do that.

Thanks
 
You should be able to use the replace function,

something like

document.write(window.location.hostname.replace(/www./i,''))
 
Status
Not open for further replies.
Top Bottom