Results 1 to 2 of 2
Oct 10, 2011, 18:11 #1
- Join Date
- Aug 2010
- 0 Post(s)
- 0 Thread(s)
this.href returns url with www prefix
I was having a seemingly intermittent problem but I was eventually able to filter it down to the following.
I use "this.href+'#sections'" in the context of jQuery .load command. when it works, it will fetch #sections part of the target page and do Ajax load on a displayed page. Sometimes this does not work.
Looking at the Chrome console, I saw a page http://mysite.com was requesting http://www.mysite.com/target.html. Since the browser considered this as a cross site reference, it refused to load the content. Obviously, when a page displayed is http://www.mysite.com, everything works.
So my question is why 'this.href' returns 'www.mysite.com' instead of 'mysite.com' even when a displayed page is without "www" prefix?
I modified the .htaccess file to redirect the www-less site request to www site and now the script always works, but this feels like a kludge.
Is this the way 'this.href' supposed to work or am I doing something wrong? Any advice is greatly appreciated.
Oct 10, 2011, 20:49 #2
- Join Date
- Jan 2007
- Christchurch, New Zealand
- 84 Post(s)
- 4 Thread(s)
If you would like clarification o this, please provide a test version of the code that you had a bad experience on, so that additional testing by us can help to narrow down the scope of things to the actual cause of the problem.