Question : Javascript URL match & redirect

I have a Javascript file that is used by many domains.

When it is called up from one particular domain, I would like to redirect to a certain URL. However this simple code does not work, and I'd be grateful if someone could show me the error of my ways.

Assume I want to redirect pages on "problem-domain.com" to "good-domain.com"...

1:
2:
var s = document.url;
if(s.match(/problem-domain/)) { location.href='http://www.good-domain.com'; } 

Answer : Javascript URL match & redirect

1. it is document.URL
2. perhaps you want location.host
3. you want to do a location.replace(location.href.replace(location.host,'www.good-domain.com'))

1:
2:
3:
4:
5:
6:
7:
<html>
<head>
<script type="text/javascript">
if (location.host.match(/mobile.experts-exchange.com/) {
  location.replace(location.href.replace(location.host,'www.e-e.com'))
}
</script>
Random Solutions  
 
programming4us programming4us