I want a web page in my site to auto load a different document or execute a block of code if window.location.host == "subdomain.mywebsite.com" and it should load a new document if window.location.host == "mywebsite.com".
I have tried using the if…else statement with logical operators but it seems it not working, this is my code.
<!DOCTYPE html>
<html>
<script>
var ATurl=window.location.host;
document.write(ATurl);
if(ATurl == downloads.wping.tk) {
document.write("--an html function to execute here--");
)
else {
document.write("--another html function to execute here!--");
}
</script>
</html>
can someone help me out with the code. Perhaps am wrong somewhere! Thanks
There are two things wrong in your code
in line 8
)should be replaced with a}to properly close the if statement
in line 6
if(ATurl == downloads.wping.tk) {You are trying to acces
tka propertie ofwpingindownloadsYou want to compare
ATurlagainst a String so put"arounddownloads.wping.tkThen you should end up with this
Heres a Fiddle for you