adm1adm
adm1adm

Reputation: 43

Script to change website text based on domain name

Is there an easy way to change a line of html text on a web page(e.g. a welcome message), based on the Domain Name?

e.g.

Is there a script to change the text dynamically based on which domin name is accessed?

Thank you

Upvotes: 3

Views: 2192

Answers (2)

JKhan
JKhan

Reputation: 90

This is how you would do it in Javascript

var url = window.location.host;
if (url == "stackoverflow.com"){
  // Make this visible
  document.getElementById("one").style.display = "block";
  // Make this invisible
  document.getElementById("two").style.display = "none";
} else {
  // Make this invisible
  document.getElementById("one").style.display = "none";
  // Make this visible
  document.getElementById("two").style.display = "block"; 
}
<div id="one">ONE</div>
<div id="two">TWO</div>

Upvotes: 1

nobody
nobody

Reputation: 10645

if( $_SERVER[ 'HTTP_HOST' ] == 'mydomain.com' ) {
    $text = "Welcome to our USA website";
} elseif( $_SERVER[ 'HTTP_HOST' ] == 'mydomain.co.uk' ) {
    $text = "Welcome to our UK website";
}

Upvotes: 4

Related Questions