Changing a URL in a Object
Hello Guru's,
I've been pushing myself to learn javascript and I'm ever so slowly gaining some insight in this strange beast. I'm currently attempting to figure out how to change a url that I've loaded into a object that I parsed from an xml file.
I'm using the kitchen sink example here,
row.url = item.getElementsByTagName("link").item(0).text;
I can correctly assume that when my xml document is parsed, anything in the <link> </link> will be saved to "link".
My xml is generating http://www.website.com/forum/thread000000/pg1 links. I would like to change my www. to m. (mobile version) to load in my created "webview" when the row is selected
I do feel it would be easier to just generate a new xml file that's a pointer solely for the mobile enviroment, HOWEVER, I would like this problem solved so I can add it to my knowledge.
Thank you in advance for taking a look at my question.
1 Answer
-
If i where you, i would have done the following:
download this function:
http://phpjs.org/functions/substr:558Then use the following code:
var url = "http://www.website.com/forum/thread000000/pg1"; var url2 = "http://m"+substr(url, 10); alert(url2);