Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

location.hostname

SpaceshipSpaceship
NamecheapNamecheap
Namecheap AuctionsNamecheap Auctions
Watch

TheWatcher

Founder, MAJ.COM QUE.COMTop Member
Impact
1,000
I'm using location.hostname in javascript to display the domain name for my website.

For example, if you go to domain.com location.hostname will show domain.com. If you go to www.domain.com, the location.hostname will also display www.domain.com.

I want to just display the domain name as formatted like Domain.com capital first letter and no www in front. I saw this script before and I can't find it. I even saw something that it will automatically use letter image to display your location.hostname result. Care to share if you know this script.
 
Last edited:
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
PHP Alternative (Supported on more browsers)

PHP:
<?php echo ucwords(str_replace("www.","",$_SERVER['HTTP_HOST')); ?>

Untested.
 
0
Close
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

The forum home page in the new NamePros Dark style
NamePros Dark has a new look
The dark style of the forum is now darker. The page is close to black, with a slight blue tint. New style: NamePros Dim Do you...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back