Js click to copy the text to the clipboard, copy the image to the clipboard, js clipboard
Copy text:
[Html]View plaincopy
- <Table width = "99%" border = "0" cellpadding = "0" cellspacing = "0" class = "firtable">
- <Tr>
- <Th width = "100%" style = "color: white;"> <s: text name = "ticket details"> </s: text> </th>
- </Tr>
- <Tr>
- <Td align = "center">
- <Textarea name = "inquiryContact1" id = "inquiryContact1" rows = "15" cols = "60" readonly = "readonly"> </textarea>
- <Div id = "inquiryInfoDIV" style = "display: none">
- <S: property value = "inquiryContact" escape = "false"/>
- </Div>
- <Script> dojo. byId ("inquiryContact1"). innerText = dojo. byId ("inquiryInfoDIV"). innerText;
- </Script>
- </Td> </tr>
- <Tr>
- <Td align = "center">
- <Input type = "button" id = "button" name = "button" value = "copy" onclick = "copyContact ()"/>
- </Td> </tr> </table>
[Javascript]View plaincopy
- <Script type = "text/javascript">
- Var I = 0;
- Function copyContact (){
- Var contat = document. getElementById ("inquiryContact1"). value;
- Window. clipboardData. setData ('text', contat );
- If (window. clipboardData. getData ('text') = ''){
- If (I = 1 ){
- Alert ("failed to copy. Please manually press Ctrl + C to copy! ");
- } Else {
- Alert ("copying failed. Please copy again! ");
- I = 1;
- }
- } Else {
- Alert ("the content has been copied to the clipboard! ");
- }
- }
- </Script>
Copy image:
[Html]View plaincopy
- <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
- <Html>
- <Head>
- <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
- <Title> Insert title here </title>
- <Script language = "JScript">
- Var oPopup = window. createPopup ();
- Function ButtonClick (div)
- {
- // Var div = document. getElementById ('divid ');
- Div. contentEditable = 'true ';
- Var controlRange;
- If (document. body. createControlRange ){
- ControlRange = document. body. createControlRange ();
- ControlRange. addElement (div );
- ControlRange.exe cCommand ('copy ');
- }
- Div. contentEditable = 'false ';
- }
- </SCRIPT>
- </Head>
- <Body>
- <Div id = "divId1">
- </Div>
- </BODY>
- </Body>
- </Html>
Js to copy the database image to the clipboard
I have tried text placement, but I have never tried square images.
However, you can refer to js for reference ~, You can try it by yourself. If it succeeds, let me know.
<Script>
Function copyToClipboard ()
{
Var d = document. all ("source"). value;
Window. clipboardData. setData ('text', d );
}
</Script>
<BODY>
<Button onclick = "copyToClipboard ();"> copy </button>
<Input type = "text" size = 20 id = "source" value = "Test Data">
<Br>
<Button onclick = "alert (window. clipboardData. getData ('text');"> display </button>
<Button onclick = "window. clipboardData. clearData ('text');"> clear </button>
</BODY>
How to copy data to the clipboard using js?
I have tried text placement, but I have never tried square images.
However, you can refer to js for reference ~, You can try it by yourself. If it succeeds, let me know.
Script
Function copyToClipboard ()
{
Var d = document. all ("source"). value;
Window. clipboardData. setData ('text', d );
}
/Script
BODY
Button onclick = "copyToClipboard ();" copy/button
Input type = "text" size = 20 id = "source" value = "Test Data"
Br
Button onclick = "alert (window. clipboardData. getData ('text');" display/button
Button onclick = "window. clipboardData. clearData ('text');" Clear/button
/BODY