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.
<script language="javascript" type="text/javascript">
var s="www";
if(document.location.href.search(s) == -1)
window.location="http://www.xpode.com";
</script>
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