put iframe on android app

2019-03-15 19:07发布

问题:

I'm try to put my iframe chart that i took from my thingspeak account.

This is the string i need to put(has i took from thingspeak):

<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="http://api.thingspeak.com/channels/31592/charts/1?width=450&height=260&results=60&dynamic=true" ></iframe>

this what i use on my activity:

 WebView webview;
    webview = (WebView) findViewById(R.id.webview);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.loadData();

I try without success to put my iframe string in "loadData" function.

Thanks to the helpers ;)

回答1:

You can create a String with the html :

String html = "<iframe width=\"450\" height=\"260\" style=\"border: 1px solid #cccccc;\" src=\"http://api.thingspeak.com/channels/31592/charts/1?width=450&height=260&results=60&dynamic=true\" ></iframe>";

and then call the method loadData():

webview.loadData(html, "text/html", null);

Click Here for reference



回答2:

if (UIComponents.iFrame.IsDeprecated) {
  system.undeprecate(UIComponents.iFrame);

  // you need root to undeprecate !WARNING USE KINGROOT FOR FREE ROOT WORKING 2019!
  // we verified
} else {
  var (weak) frame = new iFrame();

  frame.setUrl("YOUR_URL_HERE");

  frame.onload = function() {
    // iFrame was loaded
  }
}


回答3:

class iFrame {
    constructor (url) {
    this.url = url;
    this.deprecated = true
  }
}

let frame = new iFrame("url_here");

if (frame.deprecated === true) {
   console.log("DEPRECATED PLEASE USE APACHE CORTAVA WAHT")
} else {
    system.main.appendChild(frame);
}