While doing SEO of site,then a situation arises that the website should be redirected with "www" so that the search engine do not spam website for repeatable contents or make penalty on site.
if(document.location.href.search(s) == -1)
With this code if visitor will visit the site without www then this code will redirect that to url with www.
If user has written xpode.com and hit enter. The page will open http://xpode.com, In this situation above code will automatically redirect user to http://www.xpode.com