PDA

View Full Version : javascript help: copy string to clipboard in non-IE browsers


Upchurch
11th August 2005, 03:10 PM
Currently, the "Link to this post" link will only copy the post's url to the clipboard in IE. This is primarily due to the limited scope of my knowledge of javascript. I'd like to expand this ability to other browsers, but I'm about fried at the moment. So, I thought I'd appeal to the board for help. What do I need to add to make this work on non-IE browsers?

to save you a hunt through the source code, here's the current function:
function show_link(num) {
var prompt_thread = "Copy the below URL to link directly to this post.\rClicking OK will copy the link to your clipboard in IE only.";
var post_link = 'http://forums.randi.org/showthread.php?postid='+num+'#post'+num;
var response = prompt(prompt_thread, post_link);
if (response != null) {
window.clipboardData.setData("Text", response);
}
}

cyborg
12th August 2005, 09:52 AM
What do I need to add to make this work on non-IE browsers?

By the looks of it changing ECMA script - this is not a standard method of the window object. You seem to be in luck as far as Mozilla based browsers go though:

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20233392.html