like i need to copy something to my clipboard by pressing a button. i can echo the value into a hidden form input field i guess. how can i get the value copied to clipboard?

Recommended Answers

You can achieve this by writing a javascript function like below:

function copyToClipboard(s)
{
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", s);
	}
}
Jump to Post

Firefox doesn't provide such coding ability.

Jump to Post

All 7 Replies

You can achieve this by writing a javascript function like below:

function copyToClipboard(s)
{
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", s);
	}
}

that code doesnt work sadly

Try with document.execCommand

document.execCommand("copy",false,text)

Try with document.execCommand

document.execCommand("copy",false,text)

it doesnt work in forefox

Firefox doesn't provide such coding ability.

i heard theres a way to do it with flash?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.