For non-ie browsers, Flash is used for implementation. jsCodeAs follows:
< Script Type = " Text/JavaScript " >
Function Copy_code (copytext)
{
If (Window. clipboardData)
{
Window. clipboardData. setdata ( " Text " , Copytext)
}
Else
{
VaR Flashcopier = ' Flashcopier ' ;
If ( ! Document. getelementbyid (flashcopier ))
{
VaR Divholder = Document. createelement ( ' Div ' );
Divholder. ID = Flashcopier;
Document. Body. appendchild (divholder );
}
Document. getelementbyid (flashcopier). innerhtml = '' ;
VaR Divinfo = ' <Embed src = "../JS/_clipboard.swf" flashvars = "Clipboard = ' + Encodeuricomponent (copytext) + ' "Width =" 0 "Height =" 0 "type =" application/X-Shockwave-flash "> </embed> ' ;
Document. getelementbyid (flashcopier). innerhtml = Divinfo;
}
Alert ( ' Copy successful! ' );
}
< / SCRIPT>
< Input ID = " Inputtest " Type = " Button " Value = " Test " Onclick = " Copy_code ('Copy successful! Sailing bookclub http://www.fanchuanbook.com ') " / >
Download the Flash file from here: Download