【问题标题】:put iframe on android app将 iframe 放在 Android 应用程序上
【发布时间】:2015-04-05 23:06:25
【问题描述】:

我正在尝试放置从我的 thingspeak 帐户中获取的 iframe 图表。

这是我需要输入的字符串(我是从 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>

这是我在活动中使用的:

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

我尝试将 iframe 字符串放入“loadData”函数中,但没有成功。

感谢帮助者;)

【问题讨论】:

    标签: android iframe webview


    【解决方案1】:

    您可以使用 html 创建一个 String

    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>";
    

    然后调用方法loadData():

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

    Click Here for reference

    【讨论】:

    • 嗨@Arlind 我试过你的网址它工作正常,但我的网址不工作
    • String html = "";
    【解决方案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);
      }
      

      【讨论】:

        猜你喜欢
        • 2017-11-27
        • 2023-03-29
        • 1970-01-01
        • 2020-12-19
        • 2012-07-19
        • 1970-01-01
        • 2018-06-22
        • 2011-07-21
        • 2011-09-18
        相关资源
        最近更新 更多