Having two environments:
http://www.example1.com
http://www.example2.com
And having the same html for both environments:
<b>We are in $variable</b>
Is it possible to display the information depending of the environment were we are?
For example: If we are in example1, show:
<b>We are in the first environment</b>
If we are in the second, then:
<b>We are in the second environment</b>
A potential solution would be to look at the host and then act accordingly. Like so:
if (document.location.host == "stacksnippets.net") {
document.getElementById('number').innerHTML = "first";
} else {
document.getElementById('number').innerHTML = "second";
}
<p>We are in the <span id="number">unknown</span> environment.</p>
Tested successfully on desktop in Firefox, Chrome, Opera and Edge. Tested successfully on mobile in Chrome.