Mozilla サポートの検索

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

詳しく学ぶ

このスレッドはアーカイブに保管されました。 必要であれば新たに質問してください。

Copy adding extra space at beginning when double clicking to select text

more options

I have to copy/paste a certain area of text many times per day, because there are many unique identifiers for a form I fill out. I double click the line to copy it and when I paste it, there is a space at the beginning which causes unneeded headaches. It works fine in Chrome.

When I view the selection source, for some reason it's also grabbing the "</div>" tag just before the text. I believe this is the cause of the space. Any thoughts on how I can fix this?

I have to copy/paste a certain area of text many times per day, because there are many unique identifiers for a form I fill out. I double click the line to copy it and when I paste it, there is a space at the beginning which causes unneeded headaches. It works fine in Chrome. When I view the selection source, for some reason it's also grabbing the "</div>" tag just before the text. I believe this is the cause of the space. Any thoughts on how I can fix this?

この投稿は ncksta により に変更されました

選ばれた解決策

I see now. Floating the <div> affects how Firefox selects a "word". It captures the suppressed line break before the word. You can see that when you paste into a multiline text box (<textarea>) like this one. When you paste into a single line control like a regular textbox (<input type=text">) the line break turns into a space.

There are several possible ways to "hack" around this. One would be to override the style rules of the page along these lines:

For tag:

<div class="float-left" style="width: 200px;">U-ID: </div>

div.float-left {
  float:none !important;
  display:inline !important;
}

I think this would give the same appearance without the problem. I don't have a way to test it in your page, but here's a demo of the change:

http://jsfiddle.net/3mbye/

この回答をすべて読む 👍 0

すべての返信 (7)

more options

I can't seem to create the result you're getting. I know that if I select a table cell boundary, I get a tab as the first character when I paste, but a closing </div> tag isn't doing anything on my made up test page.

By the way, when I double-click, Firefox selects the current word; are you sure you're double-clicking and not triple-clicking?

When I triple-click, Firefox selects the entire paragraph. In order to more closely match your scenario, I can set triple-click to select only the current line instead of the complete paragraph, as follows:

(1) In a new tab, type or paste about:config in the address bar and press Enter. Click the button promising to be careful.

(2) In the search box above the list, type or paste click and pause while the list is filtered

(3) Double-click the browser.triple_click_selects_paragraph preference to switch it from its default value of true to false.

But still no extra space at the beginning. Maybe it's a difference between MacOS and Windows?


In case one of your extensions is involved, could you test the page in Firefox's Safe Mode? That's a standard diagnostic tool to deactivate extensions and some advanced features of Firefox. More info: Diagnose Firefox issues using Troubleshoot Mode.

You can restart Firefox in Safe Mode using either:

  • "3-bar" menu button > "?" button > Restart with Add-ons Disabled
  • (menu bar) Help > Restart with Add-ons Disabled

Not all add-ons are disabled: Flash and other plugins still run

After Firefox shuts down, a small dialog should appear. Click "Start in Safe Mode" (not Reset).

Any difference?

more options

Thank you for taking the time to reply. I've tried the configuration change and verified I am only double clicking. Safe mode yields the same results. I've attached a screenshot showing the line of code I get when viewing the selection source. It copies normally if I use Inspect Element and remove the F leaving only numbers. The letter seems to throw it off.

この投稿は ncksta により に変更されました

more options

This is still quite bothersome. Anyone else know why it may be doing this? Works fine in Safari, Chrome, & even IE. Only firefox has issues.

more options

I don't think the there is much to do about this.

Does it make a difference if you start selecting right-to-left or left-to-right?

If you select right-to-left with the mouse then you can stop before the leading 'F' and possibly add the 'F' manually (Shift and cursor left) to see if that works.

more options

選ばれた解決策

I see now. Floating the <div> affects how Firefox selects a "word". It captures the suppressed line break before the word. You can see that when you paste into a multiline text box (<textarea>) like this one. When you paste into a single line control like a regular textbox (<input type=text">) the line break turns into a space.

There are several possible ways to "hack" around this. One would be to override the style rules of the page along these lines:

For tag:

<div class="float-left" style="width: 200px;">U-ID: </div>

div.float-left {
  float:none !important;
  display:inline !important;
}

I think this would give the same appearance without the problem. I don't have a way to test it in your page, but here's a demo of the change:

http://jsfiddle.net/3mbye/

more options

Thanks! I really do appreciate your help on this one! I'll fiddle with it and try to override the style. Do you have any suggestions about the best way to do this?

この投稿は ncksta により に変更されました

more options

The two standard options for applying custom style rules to web pages are: