Note that there are some explanatory texts on larger screens.

plurals
  1. POloading html/javascript via webView
    primarykey
    data
    text
    <p>I have the following script that I need to show in a browser. I tried loading with WebView loadData and loadDataWithBaseURL but with no success (empty view). I probably miss something with the MIME, Encoding, etc.</p> <pre><code>&lt;head&gt; &lt;meta name='viewport' content='width=device-width'/&gt; &lt;script type='text/javascript' src='http://www.googletagservices.com/tag/js/gpt_mobile.js'&gt;&lt;/script&gt; &lt;script type='text/javascript'&gt;eval(window.location.search.substring(1));googletag.cmd.push(function(){googletag.defineSlot('/7047/AppCamoli_Iphone_Transition_Splash',[320,480],'div-gpt-ad-2935936626049-0').addService(googletag.pubads());googletag.enableServices();});&lt;/script&gt; &lt;/head&gt; &lt;body style="margin:0; padding: 0;"&gt; &lt;div id='div-gpt-ad-2935936626049-0'&gt; &lt;script type='text/javascript'&gt; document.getElementById('div-gpt-ad-2935936626049-0').id='div-gpt-ad-2935936626049-0';googletag.cmd.push(function(){googletag.display('div-gpt-ad-2935936626049-0')}); &lt;/script&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>The code I have is followed:</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.web); try { webView = (WebView) findViewById(R.id.webView1); webView.getSettings().setJavaScriptEnabled(true); Intent i = getIntent(); boolean typeURL = i.getBooleanExtra("urlType", true); String url = i.getStringExtra("url"); if (typeURL) webView.loadUrl(url); else { //String html = "&lt;html&gt;&lt;body&gt;You scored &lt;b&gt;hello world&lt;/b&gt; points.&lt;/body&gt;&lt;/html&gt;"; String html = "&lt;html&gt;&lt;head&gt;&lt;meta name='viewport' content='width=device-width'/&gt;&lt;script type='text/javascript' src='http://www.googletagservices.com/tag/js/gpt_mobile.js'&gt;&lt;/script&gt;&lt;script type='text/javascript'&gt;eval(window.location.search.substring(1));googletag.cmd.push(function(){googletag.defineSlot('/7047/AppCamoli_Iphone_Transition_Splash',[320,480],'div-gpt-ad-2935936626049-0').addService(googletag.pubads());googletag.enableServices();});&lt;/script&gt;&lt;/head&gt;&lt;body style='margin:0; padding: 0;'&gt;&lt;div id='div-gpt-ad-2935936626049-0'&gt;&lt;script type='text/javascript'&gt;document.getElementById('div-gpt-ad-2935936626049-0').id='div-gpt-ad-2935936626049-0';googletag.cmd.push(function(){googletag.display('div-gpt-ad-2935936626049-0')});&lt;/script&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;"; //webView.loadDataWithBaseURL(null, html, "text/javascript", "UTF-8", null); webView.loadData(html, "text/javascript", "UTF-8"); } } catch (Exception e) { Log.e("webView","failed to load URL"); e.printStackTrace(); } } </code></pre> <p>This results in an empty webView.</p> <p>Thanks,</p> <p>Simon</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload