Trying to link button to webpage
I have a button that links to a .js file with the following code:
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function()
{
sourcecode = this.responseText;
Titanium.API.info(sourcecode);
};
xhr.open("GET","http://www.887fm.org");
xhr.send();
I would like for the code to open the webpage shown, but it only shows up with a white screen. Titanium shows the html from the webpage. However, no image. So …pretty confused.
2 Answers
-
If you take a look at the webpage source you will see that al the images have relative urls.
Being relative Titanium thinks the image is local and of course displays nothing.You will need to regex the html code and add to each image the full url.
-
If I understand correctly, you simply want to show your website on the device when a user clicks the button? You don't need to use the HTTPClient for that, just use a WebView.
Here's a quick sample code: app.js