Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
(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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda