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 6770881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:21:59+00:00 2026-05-26T15:21:59+00:00

Question: how can I grab the newlines in a string entered into a textbox

  • 0

Question: how can I grab the newlines in a string entered into a textbox created as described below?

Motivation: I am trying to make a couple really simple modifications to a FireFox extension (Zotero) to make it easier for me to use. This extension allows you to enter tags for an item by typing them into a textbox and hitting enter. I would like to be able to enter a bunch of tags at once by pasting them into the textbox as a string with newline as the delimiter between tags. newline was chosen because other characters are viable choices for use in the tag itself.

Problem: when I paste a string into the entry textbox right now, it strips out all of the newlines and replaces them with single spaces. I can’t find anywhere in the extension code where this happens, so I think it is a property of the textbox itself. I am trying to look up documentation for this textbox to see if there are some properties I can play with so that I can catch the newlines, but I am not very familiar with JavaScript and HTML and am having trouble finding anything. I’d like to find the least invasive solution possible (one that doesn’t change the way the textbox currently works for typing in new entries and hitting enter) so that this modification could be adopted into the core version of the extension.

Resources: so far the only thing I have found online discussing a similar issue is this other question about allowing tab in a textbox but not newline. I am not sure if this is an HTML issue (is there a property that could be set to allow the newlines to be retained?) or a JavaScript one (do I need to rewrite the code quoted below?). I have been trying to look at documentation for both but have not found anything so far (most HTML tutorials discuss textarea rather than textbox).

Code: here is the code that creates the textbox object (or is it a method or a form?) I am dealing with:

        <method name="showEditor">
            <parameter name="elem"/>
            <body>
            <![CDATA[
                // Blur any active fields
                /*
                if (this._dynamicFields) {
                    this._dynamicFields.focus();
                }
                */

                Zotero.debug('Showing editor');

                var fieldName = 'tag';
                var tabindex = elem.getAttribute('ztabindex');

                var tagID = elem.parentNode.getAttribute('id').split('-')[1];
                var value = tagID ? Zotero.Tags.getName(tagID) : '';
                var itemID = Zotero.getAncestorByTagName(elem, 'tagsbox').item.id;

                var t = document.createElement("textbox");
                t.setAttribute('value', value);
                t.setAttribute('fieldname', fieldName);
                t.setAttribute('ztabindex', tabindex);
                t.setAttribute('flex', '1');

                // Add auto-complete
                t.setAttribute('type', 'autocomplete');
                t.setAttribute('autocompletesearch', 'zotero');
                var suffix = itemID ? itemID : '';
                t.setAttribute('autocompletesearchparam', fieldName + '/' + suffix);

                var box = elem.parentNode;
                box.replaceChild(t, elem);

                // Prevent error when clicking between a changed field
                // and another -- there's probably a better way
                if (!t.select) {
                    return;
                }

                t.select();

                t.addEventListener('blur', function () {
                    document.getBindingParent(this).blurHandler(this);
                }, false);
                t.setAttribute('onkeypress', "return document.getBindingParent(this).handleKeyPress(event)");

                this._tabDirection = false;
                this._lastTabIndex = tabindex;

                return t;
            ]]>
            </body>
        </method>
  • 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-26T15:22:00+00:00Added an answer on May 26, 2026 at 3:22 pm

    This question is actually about XUL, not HTML. The documentation for the textbox object can be found here:

    https://developer.mozilla.org/en/XUL/textbox

    The property that needs to be set is newlines. By setting this to ‘pasteintact’ the newlines can be retained.

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

Sidebar

Related Questions

My question can be boiled down to, where does the string returned from stringstream.str().c_str()
Right bit of a simple question can I input nText into a pivot table?
I have a quite stupid question. How can I make sure that my XML
I'm trying to create a data structure for three fields. One method can grab
My question is the following: How can I grab 'blocks' in a city for
This is a two part question. First how can I grab the last url
Question Can I build a image database/library that has an e-commerce style checkout system
Simple question: Can a swing frame be completely modal ( block all others windows
Simple question: Can I mix in my desktop application Java and JavaFX Script code?
this question can create a misunderstanding: I know I have to use CSS to

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.