| 1:12 am on Apr 4, 2003 (gmt 0)|
I don't quite get that error message, but isn't the pattern you want to test and split for www. (with a dot), rather than www?
| 1:23 am on Apr 4, 2003 (gmt 0)|
Split expects a delimiter or a number of characters that serve as a delimiter not a regular expression. Trying to split [webmasterworld.com...] on /www/i will not work since it does not contains that string.
Split is a method of the string object. Location returns a URI? object.
var myString = new String(document.location);
var myArray = myString.split('www.');
| 2:33 am on Apr 4, 2003 (gmt 0)|
| 4:09 am on Apr 4, 2003 (gmt 0)|
Thank you all for your comments so far.
Yes, you are right. I AM missing a dot there. But that is not the problem. Good eye.
I am pretty sure we can use regular expressions.(http://www.webreference.com/js/column5/methods.html).
The script you wrote works fine.
I also fixed my own code (with a little help from a frined).
We added a space at the end of the URL, when assigning to a var and it worked.
var current_url = document.location;
var current_url = document.location + " ";
Now I wonder why? Any thoughts on that?
| 4:15 am on Apr 4, 2003 (gmt 0)|
This will convert the URL object to a string object. I did it explicitly by creating a new string object.
| 4:21 am on Apr 4, 2003 (gmt 0)|
Ah-ha! It makes sense now. THANK YOU.
| 6:13 am on Apr 4, 2003 (gmt 0)|
why not try what i said?
both document.location.href and document.location.toString() works
will convert document.location "toString()" automaticly