I have a HTML page that contains a form with a submit button like the following:
<form action="https://www.myUrl.com/test.html" method="POST">
<input class="submit" type="submit" title="PDF (165 KB)" value="PDF (165 KB)">
</form>
When clicking on the submit button from a desktop, a PDF file is downloaded. However, when clicking the same button in the Android WebView, the same PDF file is not being downloaded.
When requesting the Url after clicking the same button, I'm always getting text/html as Content-Type
I tried requesting the url with different methods:
HttpUrlConnection:
ucon.setRequestProperty("User-Agent", params[1]);
ucon.setRequestMethod(params[2]);
ucon.connect();
String resource = ucon.getContentType();
This answer
An injected OkHttpClient
All three methods are returning the same Content-Type.
Any Ideas?
Related
I am trying to avoid future back button problems with sending form in web view to with target to iframe but target attribute not working correctly in webview...
<form action="......." enctype="multipart/form-data" id="uploadForm" data-ajax="false" target="hiddenUploadIframe" method="POST">
...
</form>
<iframe id="hiddenUploadIframe" name="hiddenUploadIframe" style="width:0; height:0; border:0; border:none"></iframe>
ANY SUGESTION ?
How to get value from html from webview using getelementbyid.
I tried several different solutions. I tried with jsoup but i cant reach targeted page becouse user need to be signed in to get to page.
This is input form, i need value data from form
<input class="form-control" id="coupon_code" name="" size="50" type="text" value="https://app.webexample.com/invite?coupon_code=6f7c0f">
also i tried to implement #JavascriptInterface but it does not work
In an Android Webview I'm displaying a page with an HTML button that only works fine when it makes a GET request. This button loads a PDF document in the browser when it's working correctly.
I need this to be a POST request, however, because I was passing a lot of data in the query string, but when making a POST request nothing happens at all (on a smartphone) or the downloaded file is corrupted (on a tablet). The same button works perfectly fine when clicked on a Windows browser, whichever of GET or POST is used.
Here's the JS code and the HTML that makes the call:
function ExportPDF()
{
var name = document.getElementById('lblName').innerHTML;
var surname = document.getElementById('lblSurname').innerHTML;
var div = '<form id="myform" method="post" action="URL"><input type="hidden" name="Name" value="'+name+'"><input type="hidden" name="Surname" value="'+surname+'"></form>';
jQuery('#divExportPDF').append(div);
jQuery('#myform').submit();
}
<button class="btnExport" onclick="ExportPDF()">EXPORT TO PDF</button>
<div id="divExportPDF"></div>
I want to Embed songs in html page . once a song is selected though file browser it should appear as thumbnail in html page.
i want function for this in html 5.
I tried with following :
function selaudio()
{
var audiopath=document.getElementById('audioFile').value;
var audiopath="somefile";
document.getElementById("audioDiv").innerHTML+="<audio src="+audiopath+" controls></audio><br/>";
}
this is my code in body :
input type="file" name="file" accept="audio/*" onclick="selaudio()" id="audioFile" value="" placeholder="Upload Audio" data-theme="b"
Check out this JSFiddle, it does exactly what you want:
http://jsfiddle.net/Tv8Cm/48/
The key is to use URL.createObjectURL, and not the raw path from the file input.
In my application, I have to make url from getting data from one static url, I have to read value from that page (means from HTML tag i.e. ) and build new url and display it in webview.
I am facing problem, how to get page source of given url and get particular tag value
like
<HTML>
<Head>
<Title>ABCDE</Title>
</Head>
<div>
<input type="hidden" name="_MYNAME" id="_MYNAME" value="" />
<input type="hidden" name="_EVENT" id="__EVENT" value="" />
<input type="hidden" name="__MYSTATE" id="__MYSTATE" value="">
</div>
I need to read value of tab , I try with htmlcleaner but I was not got success. any suggestion ?
You can use YQL (Yahoo query Language) to write query for fetching HTML data.
YQL returns JSON or XML result which you can read using HttpGet inside AsyncTask.
This is developer guide:
http://developer.yahoo.com/yql/guide/
This is the guide to read JSON response in android:
http://www.androidhive.info/2012/01/android-json-parsing-tutorial/
Just Override the onpagefinished method in WebViewClient for your webview. you just need to write some javascript to get the value fromvthe html page using name or id as simple as we are doing in simple html pages , form the url and load it using js itself
String javascript;
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
javascript="javascript:var yourValue=document.getElementById('tad_id').value;
window.location = "form your url using yourValue here";"
wv.loadUrl(javaScript);
}
I am using it to fill the form from my preferences file and working fine for me.