为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

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: