Trang web này sẽ có chức năng hạn chế trong khi chúng tôi trải qua bảo trì để cải thiện trải nghiệm của bạn. Nếu một bài viết không giải quyết được vấn đề của bạn và bạn muốn đặt câu hỏi, chúng tôi có cộng đồng hỗ trợ của chúng tôi đang chờ để giúp bạn tại @FirefoxSupport trên Twitter và /r/firefox trên Reddit.

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Tìm hiểu thêm

document.execCommand('copy') not working

  • 4 trả lời
  • 17 gặp vấn đề này
  • 1 lượt xem
  • Trả lời mới nhất được viết bởi bansal5575

more options

I am trying this small piece of code:

<textarea onselect="document.execCommand('copy');">Hello I'm some text</textarea>

It seems to work for Chrome but not for firefox. Does firefox not provide a functionality for copying contents to clipboard. I fyes, what are they because I am definately missing them.

I am getting this error on Browser console: 20:43:49.409 NS_ERROR_FAILURE: 1 try1.html:1:0

Any solutions for copying text to clipboard from firefox browsers?

I am trying this small piece of code: <textarea onselect="document.execCommand('copy');">Hello I'm some text</textarea> It seems to work for Chrome but not for firefox. Does firefox not provide a functionality for copying contents to clipboard. I fyes, what are they because I am definately missing them. I am getting this error on Browser console: 20:43:49.409 NS_ERROR_FAILURE: 1 try1.html:1:0 Any solutions for copying text to clipboard from firefox browsers?

Giải pháp được chọn

Hi bansal5575, did you follow the link to the bug tracking system? It is scheduled to appear in Firefox 41, which is about 8-9 weeks away from release.

https://developer.mozilla.org/Firefox/Releases/41#InterfacesAPIsDOM

You can test Firefox 41 in its current early form to see whether it meets your needs: https://www.mozilla.org/firefox/developer/

You probably should make a backup of your Firefox profile first. This article has tips on that: Back up and restore information in Firefox profiles.

Đọc câu trả lời này trong ngữ cảnh 👍 2

Tất cả các câu trả lời (4)

more options

Firefox doesn't allow access to the clipboard via scripts. Use keyboard shortcuts if the buttons on the web page or other methods aren't working.

  • Copy: Ctrl+C or Ctrl+Insert (Mac: Command + C)
  • Paste: Ctrl+V or Shift+Insert (Mac: Command + V)
  • Cut: Ctrl+X or Shift+Delete (Mac: Command + X)

developer.mozilla.org/en-US/Firefox/Releases/29/Site_Compatibility#Security ... See this bug:

  • bug 1012662 - Allow document.execCommand("cut"/"copy") to be used within the context of user generated events
more options

When Google Chrome seems to be providing a solution for this, why is there no support in firefox? This use case is a very important feature for one of the apps that I am developing and users won't be pleased having this feature only in chrome and not in firefox.

more options

Giải pháp được chọn

Hi bansal5575, did you follow the link to the bug tracking system? It is scheduled to appear in Firefox 41, which is about 8-9 weeks away from release.

https://developer.mozilla.org/Firefox/Releases/41#InterfacesAPIsDOM

You can test Firefox 41 in its current early form to see whether it meets your needs: https://www.mozilla.org/firefox/developer/

You probably should make a backup of your Firefox profile first. This article has tips on that: Back up and restore information in Firefox profiles.

more options

Thanks jscher2000, It is indeed working in Firefox41.