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

  • Home
  • SEARCH
  • 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 9250697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:30:28+00:00 2026-06-18T10:30:28+00:00

I have the following div in UIWebView : <div contenteditable=true></div> If the user inserts

  • 0

I have the following div in UIWebView:

<div contenteditable="true"></div>

If the user inserts new line (using the return key in the visual keyboard), and when he is done he clicks on done in the previous/next/done grey visual keyboard, it combines the lines to one line.

How can I avoid it?

While editing
After clicking done

  • 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-06-18T10:30:30+00:00Added an answer on June 18, 2026 at 10:30 am

    Perhaps this JSFiddle can shed some light onto what’s happening within your application. If you type some lines in the top DIV (gray background color), the HTML code that you get as the return value of its innerHTML property will first display in a textarea field below it (including HTML tags formatting). As you will soon see it’s not merely what you’d expect to handle in your application (‘line one’ + CRLF + ‘line two’…), but it also contains HTML elements separating lines one from another. That’s how browsers are able to display contenteditable DIVs as if they’re ‘memo’ type controls – by parsing their HTML (that’s what browsers do). This HTML formatted text is also how your application receives user submitted text, and there you have to decide what to do with this formatting. You can either strip them away (which is, I suspect, how you set that object’s property and it deals with that for you) replacing HTML elements like <DIV></DIV> and so on with a space character, or choose (with your control’s property, or in code) to handle this formatting whichever way you’d like them to be handled. I’m not familiar with UIWebView though, and you’ll have to find on your own how to retrieve complete HTML formatted values that you want to apply to the next DIV element that you’re displaying (or same one that you’re assigning new values to).

    UPDATE: After searching the web for UIWebView reference, I’ve actually stumbled across one related thread on SO that shows how to retrieve innerHTML value of an element in your underlying HTML document:

    //where 'wView' is your UIWebView
    
    NSString *webText = [wView stringByEvaluatingJavaScriptFromString:@"document.getElementById('inputDIV').innerHTML"];
    

    This way you’d be able to retrieve the whole innerHTML string contained within the contenteditable DIV that you use in a webText string variable and parse its HTML formatted text to whatever suits your needs better. Note though, that different browsers format contenteditable DIVs differently when Enter Key is pressed and some will return the next line enclosed in a new DIV, while others might enclose it in paragraph P and/or end the line with a break <BR> or <BR />, when shift+enter were used together to move to the next line. You will have to account for all these possibilities when processing your input string. Refer to the JSFiddle script I wrote using your UIWebView component to check what formatting applies.

    Of course, in your case, it might be simpler to replace your contenteditable DIV with a textarea that will return more commonly formatted \n end-of-line (CR+LF). DIVs however are easier to design, so choose whichever suits your needs better.

    Cheers!

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

Sidebar

Related Questions

I have the following div: <div contenteditable=true unselectable=off id=foo> inside this div I want
I have following PHP code $val=<div id=user.$row['cid']. userid=.$row['cid']. class=innertxt><img src=images/images.jpg width=50 height=50><strong>.$uname.</strong><ul> <li>Email: .$row['cemail'].</li>
I am using Mootools and I have the following div: <div class=total-title>12</div> I want
Possible Duplicate: jQuery refresh if PHP file echo's 'true' I have the following div
I have the following div : <div id=new style=position: absolute; z-index: 100; top: 210px;
I have following CSS: background-div: url(/images/top.png) no-repeat top center; and I am using the
I have the following div block which i'm trying to validate using the jQuery
I have following div in a page (I can not modify). <div id=:0.control>Click me</div>
I have a following div structure <div id=wrapper> <div id=header> <div id=storeFinder> /* html
I have the following div <body> <span style=border:1px solid red; display:inline-block> Some text<br />

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.