Helix
Helix

Reputation: 125

Save and retrieve HTML and .aspx Webpage in Titanium SDK

How to save and retrieve the HTML and .aspx webpage in Titanium SDK?

For display in offline.

I have seen this link. But it returns an image. I need as webpage.

Edit:- (see answer)

Now I am able to save webpage and retrieve it successfully. But inside webpage some of javascript file, images are there. how to get those files...

Upvotes: 0

Views: 80

Answers (1)

Helix
Helix

Reputation: 125

Its Work fine.

var xhr = Titanium.Network.createHTTPClient({
    onload: function(e) {
          var returnValue = this.responseText;
          Ti.API.info(this.responseText);

          var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'file.html');
                if(f.exists()==false) {
                     Ti.API.info('false');

                      // you don't need to do this, but you could...
                      f.createFile();
                }
                f.write(this.responseText);
                Ti.API.info('Files dir path : ' + Ti.Filesystem.applicationDataDirectory);

           Titanium.App.Properties.setString("URRL", Ti.Filesystem.applicationDataDirectory+'file.html');
           urrl = Ti.App.Properties.getString('URRL');
           webview.setUrl(urrl);

           },
           timeout: 10000
});
webservice();
function webservice() {
        xhr.open('GET','http://msdn.microsoft.com/en-us/library/015103yb(v=vs.100).aspx');
        xhr.send();
}

Upvotes: 1

Related Questions