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

How to implement Copy to Clipboard using javascript in Firefox

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

more options

Hello,

I am trying to implement "Copy to Clipboard" functionality in Mozilla Firefox 33.1. Simplest option is to use javascript window prompt

window.prompt("Copy to clipboard: Ctrl+C, Enter", "test");

But using this option, I can't avoid the unnecessary "Ok" and "Cancel" button in the prompt. Moreover, it opens a new tab to display the javascript prompt. I tried another way by using the following line of code in my <script> block

$('<input type="text">').appendTo('body').val("test val").select();

But it doesn't seem to work. Basically, I want to implement a popup from the same page (Spawn a text box, put the text in and select it so that the user can copy it with the platform specific key combination).

Can someone please help me to understand how I can achieve this in javascript? A working example in this regard will be very helpful.

Thanks Aditya Aery

Hello, I am trying to implement "Copy to Clipboard" functionality in Mozilla Firefox 33.1. Simplest option is to use javascript window prompt window.prompt("Copy to clipboard: Ctrl+C, Enter", "test"); But using this option, I can't avoid the unnecessary "Ok" and "Cancel" button in the prompt. Moreover, it opens a new tab to display the javascript prompt. I tried another way by using the following line of code in my <script> block $('<input type="text">').appendTo('body').val("test val").select(); But it doesn't seem to work. Basically, I want to implement a popup from the same page (Spawn a text box, put the text in and select it so that the user can copy it with the platform specific key combination). Can someone please help me to understand how I can achieve this in javascript? A working example in this regard will be very helpful. Thanks Aditya Aery

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

more options

I have uploaded an image with a possible implementation of what I am looking at. Any ideas along those lines will be very helpful.

more options

A good place to ask advice about web development is at the mozillaZine "Web Development/Standards Evangelism" forum.

The helpers at that forum are more knowledgeable about web development issues. You need to register at the mozillaZine forum site in order to post at that forum.

more options

Is this what you wanted, or something else?

RightToClick {web link} Stops javascript annoyances such as forbidden right click, forbidden text selection or cascading dialog boxes.

more options

Hello Fred,

No, not really. I am aware that "Copy to Clipboard" using javascript us not supported in Mozilla Firefox for security reasons. I wastrying to implement this "copy to clipboard" functionality in an alternate way. One possible way is to use jquery dialog and open a dialog box with link to object already selected.

Thanks Aditya Aery