Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

208
Visualizações
(Android) Javascript that is realized twice on WebView

I want to change the text in a GoogleForm via Webview, however the action happens twice.

In the text box, it has the word twice, as if the javascript happens twice.

Would you have an idea? Thanks

public class QuestionnaireFragment extends Fragment  {
//Lancement de l'activité
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState)
{
    View rootView = inflater.inflate(R.layout.fragment_questionnaire, container, false);

    WebView view = (WebView) rootView.findViewById(R.id.webview_questionnaire);
    String url = "LINK GOOGLE FORMS";
    WebSettings webSettings = view.getSettings();
    view.getSettings().setJavaScriptEnabled(true);
    view.loadUrl(url);

    view.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            String js ="javascript:document.getElementsByClassName(\"quantumWizTextinputPaperinputInput exportInput\")[0].focus(); document.execCommand('insertText', false, '" + "WORD"+ "');";

            view.loadUrl(js);

        }
         });
    return rootView;
}

}

The problem

EDIT : I change string by :

String js= "javascript:document.getElementsByClassName(\"quantumWizTextinputPaperinputInput exportInput\")[0].value=\"WORD\";";

But another probllem:

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In case 1 the word was repeated twice. In case 2 the hint was not going. So, if we use both the lines of code, we can solve the problem. So just do this and it will work:

view.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            String js ="javascript:document.getElementsByClassName(\"quantumWizTextinputPaperinputInput exportInput\")[0].focus(); document.execCommand('insertText', false, '" + ""+ "');";

            view.loadUrl(js);
            
            String js2 = "javascript:document.getElementsByClassName(\"quantumWizTextinputPaperinputInput exportInput\")[0].value=\"WORD\";";
            view.loadUrl(js2);


        }
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda