HTML TextArea Characters Limit Inside Android WebView

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?

-------------Problems Reply------------

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.

Category:java Views:0 Time:2011-02-15

Related post

  • Flash inside Android WebView - How do I set fullscreen automatically? 2011-04-14

    I am loading Flash SWFs into an Android WebView. I want the SWF to be instantly fullscreen and focused. The class name that handles flash is com.adobe.flashplayer.FlashPaintSurface. Watching the log, when I fullscreen the flash manually, it calls com

  • downloading the file inside android webview not the browser 2011-07-25

    How can I download a zip or apk file inside WebView? Because every time I click on any link inside the WebView its first open the browser I need to download a file without the browser. I am new to Java and I am really learning through stackoverflow,

  • Disable touch overlay layer on linked elements inside android WebView? 2011-10-25

    This might be a simple configuration or something, But I would like to disable blueish overlay which shows when touched on links or linked items (images or other linked stuffs) from android's WebView. For better illustration, I've added an screenshot

  • Zooming in/out on Android Webview without a set limit 2012-05-02

    In my current project I need my users to be able to scroll over and zoom in on large SVG Images. A major problem i encountered though, is the limit the android WebView class puts on zooming in and out. Is there any way I can remove or change these li

  • Android WebView with garbled UTF-8 characters. 2011-02-08

    I'm using some webviews in my android app, but are unable to make them display in utf-8 encoding. If use this one I won't see my scandinavian charcters: mWebView.loadUrl("file:///android_asset/om.html") And if try this one, I won't get anything displ

  • Android WebView inside ListView onclick event issues 2011-02-11

    I have a ListView where each row has two webviews side by side, taking up the entire row. I've set up onListItemClick() in my ListActivity, but they are not fired when I tap on one of the rows (unless the place I happen to tap is outside the webview'

  • Flip/Mirror an Image inside a Webview on Android 2011-11-15

    I'm looking to flip/mirror an image assigned to a DOM using the background property with CSS inside a Webview on Android with the following: -webkit-transform:translate3d(280px,135px,0) scale3d(-1,1,1); Now, the problem is that it seems that Android'

  • Android Full Screen Keyboard for TextField inside a webview 2011-11-28

    Usually in landscape mode an EditText will open the IME in full screen mode, but for an textfield inside a webview (loaded as a HTML content) it doesn't and it pushes the existing view upwards. I tried something like this but it has the same behaviou

  • (How) can I increase the quota limit of LocalStorage in Android WebView 2012-03-27

    I need to increase the default quota limit of the LocalStorage in a Android WebView. Currently I can only use around 2.5MB. When trying to store more data, a quota_exceeded_err (dom exception 22) is raised. Any ideas or do I have to switch to db/file

  • How can I prevent performance degradation for Canvas inside of WebView on an Android Xoom? 2012-04-12

    I've been experimenting with using a canvas inside of WebView to capture a small drawing. Testing on Chrome or on a very simple test page, the canvas performs OK. By this I mean that if I drag my finger across a 500-pixel-wide canvas, I see 60-100 to

  • Android webview SKIPS javascript even with setJavascriptEnabled(true) and WebChromeClient 2011-08-04

    (using Samsung Galaxy Tab and Android 3.0, this is intended to work on every 3.0+ tablet, like it does in their browsers, just not webview) I have a page with CSS and jQuery that loads fine in browsers, android browsers and iOS devices, but android w

  • Android WebView can't show copyright or trademark symbols? 2012-03-08

    When I display bullet-points, copyright symbols, trademark signs in a web browser, they look fine. // bullets: http://losangeles.craigslist.org/wst/acc/2900906683.html // bullets: http://losangeles.craigslist.org/lac/acc/2902059059.html // bullets: h

  • Android WebView handling orientation changes 2009-06-16

    Just started working with the webview. The issue is performance following rotation. The WebView has to reload the page, which can be a bit tedious. What's the best of of handling an orientation change without reloading the page from source each time?

  • Android WebView progress bar 2010-03-29

    I have looked at a question similar to this here but as I am a newbie could someone explain how to get this to work in a WebView or at least how to set a 10 second time delay so people know that it's loading? --------------Solutions------------- well

  • Android WebView can render HTML going forward, but not backward 2010-04-21

    I'm using a WebViewClient that overrides shouldOverrideUrlLoading so the browsing stays inside the WebView. I initially call loadDataWithBaseURL with some HTML I have in memory, which has links in it. When I click the links, they load correctly in th

  • Android::Webview removes scrollbar for a DIV 2010-05-23

    I made a small webpage with a scrollable div. When I load it in a browser, it works fine. But when I load it in a webview inside Android, it doesn't let me scroll the div. Is there a workaround for this or do I have to use a different design? I am ta

  • Android Webview Anchor Link (Jump link) not working 2010-06-14

    I have a WebView in my Android App that is loading an HTML string using the loadDataWithBaseURL() method. The problem is that local anchor links (<a href="#link">...) are not working correctly. When the link is clicked, it becomes highlighted,

  • Is there any character limit in android textview? 2010-06-17

    I'm trying to enter more than 2000 - 3000 characters in an android TextView it does not display anything. any one guide is there character limit on android textview or what ? --------------Solutions------------- I did some small testing in G3, I foun

  • setOnClickListener not response on Android WebView 2010-08-30

    I have Android LisView that was contain TextView to display the data in the list, I add to change it to Webview, after doing that everything look good except the setOnClickListener that not responding anymore.. I have read about the Webview and found

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.174 (s). 11 q(s)