multiple IF to check (sub)domain and change styling

rigequige

New Member
There is network of sites having sub-domains \[code\]domain.com.br\[/code\] , \[code\]subdomains.domain.com.br\[/code\]. A certain script of single-file JavaScript will be placed, which executes certain simple styling changes. This file uses multiple if statements for domain check. The problem I have is that I can only get to work 1 \[code\]if\[/code\] for one site, be it \[code\]domain.com.br\[/code\] or \[code\]subdomain.domain.com.br\[/code\], but when I add the rest of \[code\]IF\[/code\] statements for the rest of sub-domains, the scripts does not work anymore. Not sure if this has something to do with the JavaScript syntax or \[code\]parent.document.domain\[/code\]. I also tried \[code\]window.location.host\[/code\]. Please find an example of the script below. Does anyone spot a problem with this?\[code\]var domain = parent.document.domain;var w;var z;if (domain.indexOf('abril.com.br') > -1){ w = document.getElementById('containerBanner'); //white space behind leaderboard z = document.getElementById('publicidade_x96'); //image spanning w.style.background = 'none'; z.style.display = 'none';}if (domain.indexOf('revistaalfa.abril.com.br') > -1){ w = document.getElementById('oas-x96'); //image spanning w.style.display = 'none';}\[/code\]
 
Top