Change css on current URL

Change css on current URL

Hello, I have one CMS with fixed layout. In that I have make few changes depends on my current URL.

If I am on my home page so This class given below is

div.layout-column.column-main.with-column-1.with-column-2{
width:790;
}

And If I am of some other page so this same class look like this.

div.layout-column.column-main.with-column-1.with-column-2{
width:790;
}

I have tried it but it's not working properly.

  1. <script>
  2.  if (location.href.indexOf("example.com") == 1) {
  3.      document.write("<style>" +
  4.      "div.layout-column.column-main.with-column-1.with-column-2{" +
  5.      " width: 790px;" +
  6.      "}" +
  7.      "</style>");
  8.  }
  9.  else{
  10.  document.write("<style>" +
  11.      "div.layout-column.column-main.with-column-1.with-column-2{" +
  12.      " width: 590px;" +
  13.      "}" +
  14.      "</style>");
  15.  }
  16. </script>
I made this script but it's not give me proper output.