我查看过几十个帖子,我不会放弃找到适合我的任何内容。我得到的是一个Android和IOS应用程序,在webview中加载webview是一个谷歌表格。我需要做的是当用户填写表单并点击提交时我需要将特定字段捕获到变量然后在下一次加载时将变量的内容放回去,这样他们就不必每次都输入类似字段的字段。
目前专注于Android部分我得到了这个代码:
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.getSettings().setDomStorageEnabled(true);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("website.com");
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.setWebViewClient(new WebViewClient());
String name = "example";
String email = "example";
myWebView.loadUrl("javascript: {" +
"document.getElementsByjsname('W85ice').value = '"+email +"';" +
"document.getElementsBylabel('Your Name').value = '"+name+"';" +
"var frms = document.getElementsByName('submit');" +
"frms[0].submit(); };");
表单中的代码是
<div class="quantumWizTextinputPaperinputEl freebirdFormviewerViewItemsTextShortText freebirdFormviewerViewItemsTextEmail freebirdThemedInput" jscontroller="pxq3x" jsaction="clickonly:KjsqPd; focus:Jt1EX; blur:fpfTEe; input:Lg5SV;" jsshadow="" jsname="W85ice"><div class="quantumWizTextinputPaperinputMainContent exportContent"><div class="quantumWizTextinputPaperinputContentArea exportContentArea"><div class="quantumWizTextinputPaperinputInputArea"><input type="email" class="quantumWizTextinputPaperinputInput exportInput" jsname="YPqjbf" autocomplete="off" tabindex="0" aria-label="Work Email Address" aria-describedby="i.desc.1470811872 i.err.1470811872" name="entry.2089120054" value="" required="" dir="auto" data-initial-dir="auto" data-initial-value=""><div jsname="LwH6nd" class="quantumWizTextinputPaperinputPlaceholder exportLabel">Your answer</div></div><div class="quantumWizTextinputPaperinputUnderline exportUnderline"></div><div jsname="XmnwAc" class="quantumWizTextinputPaperinputFocusUnderline exportFocusUnderline animationInitialized" style="transform-origin: 82px center 0px;"></div></div></div><div class="quantumWizTextinputPaperinputCounterErrorHolder"><div jsname="ty6ygf" class="quantumWizTextinputPaperinputHint exportHint"></div></div></div>
我没有得到任何错误,但我也没有得到任何结果我试图拉不同的ID,但没有任何工作。任何帮助,将不胜感激。这是我工作的一个辅助项目。