Reputation: 43
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
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
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