Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3977410
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:55:14+00:00 2026-05-20T04:55:14+00:00

I have written a HTML page which has following code. <div id=adsListContainer style=margin: 5px;>

  • 0

I have written a HTML page which has following code.

<div id="adsListContainer" style="margin: 5px;">
    <textarea id="txtDesc" rows="20" cols="50"></textarea>
    <br />
    <input id="txtCounts" value="0" size="8" />
    <input type="button" value="Count" onclick="countChars()" />
</div>

The above html is enclosed in a file named test.html and it’s being shown in android’s WebView control. Now using Java and WebView’s loadURL() function I am executing javascript as to write something in that textarea as following code goes.

javascript:document.getElementsByTagName("textarea")[0].value += 'anything goes here of not more than 50 chars';void(0);

Even thought the above code works and I am calling it many times so I may insert 7000+ characters in this textarea element.

The Java code responsible for executing Javascript to insert text (HTML) into textarea is as follows.

int bStart = 0;
int bEnd = 49;
String description = "some huge description including html tags"
int totalChars = description.length() - 1;

while (bStart <= totalChars) {
    if (bEnd > totalChars)
        bEnd = totalChars;

    rv = "javascript:";

    rv += "var tas=document.getElementsByTagName('textarea');"; // description
    rv += "if (tas.length>0) {";
    rv += "var ta=tas[0];";
    rv += "ta.value += '"
           + description.substring(bStart, bEnd)
            .replace("'", "\\'").replace('"', '\"') + "';"; // description
    rv += "}";

    webView.loadUrl(rv + "void(0);");

    bStart += 50;
    bEnd += 50;
}

Although the above code works but not perfectly. The description has 7245 characters but it only insert 6267 characters into textarea of the web page.

Is there something I am missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:55:14+00:00Added an answer on May 20, 2026 at 4:55 am

    I have tried to apply your issue only with HTML + JavaScript. Please see this fiddle.

    As you can see, this is working properly. So, I think the issue may be with replacement of escape sequence characters. See that you are changing the escape sequence character from within the loop that will increase the size of description variable. But, totalChars has the size which is previously stored size of description. So, later when you apply “bStart <= totalChars” condition, it will count till the totalChars only (i.e. already less then the current size).

    Concluding, your description has too many escape sequences characters “may be” generating this problem. So, replace the whole string previously & then add substrings to your javaScript.

    This may or may not solve your issue if there is any another one, still. So, please correct me if I am wrong.

    Thank you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some code in my VB.NET application to send an HTML e-mail
I have written an Excel VBA macro which imports data from a HTML file
I have written jQuery code, in files Main.html and ajax.php . The ajax.php file
I have written a ruby script which opens up dlink admin page in firefox
I have written following function which checks whether start_date field is not empty and
I have written a simple helloworld app with a WebView which has a link
I have written a small HTML form and added it to the page. My
I have written an AppleScript which when supplied with a Windows network link, will
I have written something that uses the following includes: #include <math.h> #include <time.h> #include
I have a some html being generated by JQuery on a Share Point page.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.