Is there an equivalent to window.clipboardData in Microsoft Edge?
In our application, we have a custom paste function that calls window.clipboardData.getData("Text") to get the current clipboard data. It then performs some functions on this data. In Edge, window.clipboardData is undefined. It does seem that getData works when used within the "paste" event though such as the following.
document.addEventListener("paste", function(e) {
var test = e.clipboardData.getData("text/plain");
});
I potentially can design a workaround that will involve this overriding of the paste event, but it would be non-ideal. A solution that can be called outside of an event would be preferable.
As an aside, I read that Edge did not support the clipboard API at one point, but my understanding is that this is fixed, so please find something specifically sustantiating the current functionality (e.clipboardData working but no equivalent to window.clipboardData existing if that is your answer.
javascript microsoft-edge
add a comment |
In our application, we have a custom paste function that calls window.clipboardData.getData("Text") to get the current clipboard data. It then performs some functions on this data. In Edge, window.clipboardData is undefined. It does seem that getData works when used within the "paste" event though such as the following.
document.addEventListener("paste", function(e) {
var test = e.clipboardData.getData("text/plain");
});
I potentially can design a workaround that will involve this overriding of the paste event, but it would be non-ideal. A solution that can be called outside of an event would be preferable.
As an aside, I read that Edge did not support the clipboard API at one point, but my understanding is that this is fixed, so please find something specifically sustantiating the current functionality (e.clipboardData working but no equivalent to window.clipboardData existing if that is your answer.
javascript microsoft-edge
add a comment |
In our application, we have a custom paste function that calls window.clipboardData.getData("Text") to get the current clipboard data. It then performs some functions on this data. In Edge, window.clipboardData is undefined. It does seem that getData works when used within the "paste" event though such as the following.
document.addEventListener("paste", function(e) {
var test = e.clipboardData.getData("text/plain");
});
I potentially can design a workaround that will involve this overriding of the paste event, but it would be non-ideal. A solution that can be called outside of an event would be preferable.
As an aside, I read that Edge did not support the clipboard API at one point, but my understanding is that this is fixed, so please find something specifically sustantiating the current functionality (e.clipboardData working but no equivalent to window.clipboardData existing if that is your answer.
javascript microsoft-edge
In our application, we have a custom paste function that calls window.clipboardData.getData("Text") to get the current clipboard data. It then performs some functions on this data. In Edge, window.clipboardData is undefined. It does seem that getData works when used within the "paste" event though such as the following.
document.addEventListener("paste", function(e) {
var test = e.clipboardData.getData("text/plain");
});
I potentially can design a workaround that will involve this overriding of the paste event, but it would be non-ideal. A solution that can be called outside of an event would be preferable.
As an aside, I read that Edge did not support the clipboard API at one point, but my understanding is that this is fixed, so please find something specifically sustantiating the current functionality (e.clipboardData working but no equivalent to window.clipboardData existing if that is your answer.
javascript microsoft-edge
javascript microsoft-edge
edited Nov 28 '18 at 17:30
TylerH
15.4k105067
15.4k105067
asked Nov 12 '18 at 23:05
Brandon Barkley
406312
406312
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Edge, like all modern browsers uses the official ClipboardEvent::clipboardData:
inp.onpaste = evt =>
console.log(evt.clipboardData.getData('text'));
<input id="inp">
Go with it. The deprecated and non-standard window::clipboardData should only be used as a mean of legacy support, for older versions of IE.
As to what you wish to do, (paste without user interaction), that goes against the specs recommendations for privacy. You won't be able to do from web-content. You'll need to run your script from an high-privilege script, like an extension.
• Implementations must not let scripts create synthetic clipboard events to get access to real clipboard data (unless the user has configured it to do so).
1
The OP wants to paste without user interaction.
– Poul Bak
Nov 12 '18 at 23:57
2
@PoulBak they can't. MS fixed this issue in Edge.
– Kaiido
Nov 12 '18 at 23:59
1
I'm glad to hear that, but OP is probably not.
– Poul Bak
Nov 13 '18 at 0:01
From a privacy perspective I'm glad too. From a "getting my intranet system browser compatible" perspective, not so much. I needed support for both pasting into a single field and having tab-delimited data pasting replace multiple fields/lines in a grid. We had a button for the second type of paste in the past, but now I have a workaround overriding the paste event. I'll post an answer with my code.
– Brandon Barkley
Nov 14 '18 at 14:16
1
@BrandonBarkley if it's for your intranet can't you simply set up an extension on all the posts? Extensions can access clipboard data with no restriction (when granted the clipboardRead permission). developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/…
– Kaiido
Nov 14 '18 at 14:18
|
show 1 more comment
As Kaiido noted, it is not possible to get at the pasted content outside of the paste event in Edge (and Chrome for that matter).
Users previously used a custom right-click menu to access "Paste From Excel" functionality to replace content in an editable grid with tab-delimited content from the clipboard. If window.clipboardData is undefined the user received a message saying that you must use the standard CTRL+V paste in this browser.
I then added the listener below which essentially determined if the content was tab-delimited and treated it as a "Paste from Excel" whereas it treated other data layouts as a standard "Paste". This was sufficient for my deployment, but for others, it may be worthwhile to launch a confirm window to verify intention.
document.getElementById(myGridID).addEventListener("paste", function(e) {
var clipboardContent = window.clipboardData ? window.clipboardData.getData("Text") : (e.clipboardData ? e.clipboardData.getData("text/plain") : "");
if(clipboardContent != null && clipboardContent.indexOf('t') >= 0)
{
MyExcelPasteFunction(myGridID, clipboardContent);
e.preventDefault();
}
});
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271387%2fis-there-an-equivalent-to-window-clipboarddata-in-microsoft-edge%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Edge, like all modern browsers uses the official ClipboardEvent::clipboardData:
inp.onpaste = evt =>
console.log(evt.clipboardData.getData('text'));
<input id="inp">
Go with it. The deprecated and non-standard window::clipboardData should only be used as a mean of legacy support, for older versions of IE.
As to what you wish to do, (paste without user interaction), that goes against the specs recommendations for privacy. You won't be able to do from web-content. You'll need to run your script from an high-privilege script, like an extension.
• Implementations must not let scripts create synthetic clipboard events to get access to real clipboard data (unless the user has configured it to do so).
1
The OP wants to paste without user interaction.
– Poul Bak
Nov 12 '18 at 23:57
2
@PoulBak they can't. MS fixed this issue in Edge.
– Kaiido
Nov 12 '18 at 23:59
1
I'm glad to hear that, but OP is probably not.
– Poul Bak
Nov 13 '18 at 0:01
From a privacy perspective I'm glad too. From a "getting my intranet system browser compatible" perspective, not so much. I needed support for both pasting into a single field and having tab-delimited data pasting replace multiple fields/lines in a grid. We had a button for the second type of paste in the past, but now I have a workaround overriding the paste event. I'll post an answer with my code.
– Brandon Barkley
Nov 14 '18 at 14:16
1
@BrandonBarkley if it's for your intranet can't you simply set up an extension on all the posts? Extensions can access clipboard data with no restriction (when granted the clipboardRead permission). developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/…
– Kaiido
Nov 14 '18 at 14:18
|
show 1 more comment
Edge, like all modern browsers uses the official ClipboardEvent::clipboardData:
inp.onpaste = evt =>
console.log(evt.clipboardData.getData('text'));
<input id="inp">
Go with it. The deprecated and non-standard window::clipboardData should only be used as a mean of legacy support, for older versions of IE.
As to what you wish to do, (paste without user interaction), that goes against the specs recommendations for privacy. You won't be able to do from web-content. You'll need to run your script from an high-privilege script, like an extension.
• Implementations must not let scripts create synthetic clipboard events to get access to real clipboard data (unless the user has configured it to do so).
1
The OP wants to paste without user interaction.
– Poul Bak
Nov 12 '18 at 23:57
2
@PoulBak they can't. MS fixed this issue in Edge.
– Kaiido
Nov 12 '18 at 23:59
1
I'm glad to hear that, but OP is probably not.
– Poul Bak
Nov 13 '18 at 0:01
From a privacy perspective I'm glad too. From a "getting my intranet system browser compatible" perspective, not so much. I needed support for both pasting into a single field and having tab-delimited data pasting replace multiple fields/lines in a grid. We had a button for the second type of paste in the past, but now I have a workaround overriding the paste event. I'll post an answer with my code.
– Brandon Barkley
Nov 14 '18 at 14:16
1
@BrandonBarkley if it's for your intranet can't you simply set up an extension on all the posts? Extensions can access clipboard data with no restriction (when granted the clipboardRead permission). developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/…
– Kaiido
Nov 14 '18 at 14:18
|
show 1 more comment
Edge, like all modern browsers uses the official ClipboardEvent::clipboardData:
inp.onpaste = evt =>
console.log(evt.clipboardData.getData('text'));
<input id="inp">
Go with it. The deprecated and non-standard window::clipboardData should only be used as a mean of legacy support, for older versions of IE.
As to what you wish to do, (paste without user interaction), that goes against the specs recommendations for privacy. You won't be able to do from web-content. You'll need to run your script from an high-privilege script, like an extension.
• Implementations must not let scripts create synthetic clipboard events to get access to real clipboard data (unless the user has configured it to do so).
Edge, like all modern browsers uses the official ClipboardEvent::clipboardData:
inp.onpaste = evt =>
console.log(evt.clipboardData.getData('text'));
<input id="inp">
Go with it. The deprecated and non-standard window::clipboardData should only be used as a mean of legacy support, for older versions of IE.
As to what you wish to do, (paste without user interaction), that goes against the specs recommendations for privacy. You won't be able to do from web-content. You'll need to run your script from an high-privilege script, like an extension.
• Implementations must not let scripts create synthetic clipboard events to get access to real clipboard data (unless the user has configured it to do so).
inp.onpaste = evt =>
console.log(evt.clipboardData.getData('text'));
<input id="inp">
inp.onpaste = evt =>
console.log(evt.clipboardData.getData('text'));
<input id="inp">
edited Nov 13 '18 at 0:04
answered Nov 12 '18 at 23:51
Kaiido
39k45799
39k45799
1
The OP wants to paste without user interaction.
– Poul Bak
Nov 12 '18 at 23:57
2
@PoulBak they can't. MS fixed this issue in Edge.
– Kaiido
Nov 12 '18 at 23:59
1
I'm glad to hear that, but OP is probably not.
– Poul Bak
Nov 13 '18 at 0:01
From a privacy perspective I'm glad too. From a "getting my intranet system browser compatible" perspective, not so much. I needed support for both pasting into a single field and having tab-delimited data pasting replace multiple fields/lines in a grid. We had a button for the second type of paste in the past, but now I have a workaround overriding the paste event. I'll post an answer with my code.
– Brandon Barkley
Nov 14 '18 at 14:16
1
@BrandonBarkley if it's for your intranet can't you simply set up an extension on all the posts? Extensions can access clipboard data with no restriction (when granted the clipboardRead permission). developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/…
– Kaiido
Nov 14 '18 at 14:18
|
show 1 more comment
1
The OP wants to paste without user interaction.
– Poul Bak
Nov 12 '18 at 23:57
2
@PoulBak they can't. MS fixed this issue in Edge.
– Kaiido
Nov 12 '18 at 23:59
1
I'm glad to hear that, but OP is probably not.
– Poul Bak
Nov 13 '18 at 0:01
From a privacy perspective I'm glad too. From a "getting my intranet system browser compatible" perspective, not so much. I needed support for both pasting into a single field and having tab-delimited data pasting replace multiple fields/lines in a grid. We had a button for the second type of paste in the past, but now I have a workaround overriding the paste event. I'll post an answer with my code.
– Brandon Barkley
Nov 14 '18 at 14:16
1
@BrandonBarkley if it's for your intranet can't you simply set up an extension on all the posts? Extensions can access clipboard data with no restriction (when granted the clipboardRead permission). developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/…
– Kaiido
Nov 14 '18 at 14:18
1
1
The OP wants to paste without user interaction.
– Poul Bak
Nov 12 '18 at 23:57
The OP wants to paste without user interaction.
– Poul Bak
Nov 12 '18 at 23:57
2
2
@PoulBak they can't. MS fixed this issue in Edge.
– Kaiido
Nov 12 '18 at 23:59
@PoulBak they can't. MS fixed this issue in Edge.
– Kaiido
Nov 12 '18 at 23:59
1
1
I'm glad to hear that, but OP is probably not.
– Poul Bak
Nov 13 '18 at 0:01
I'm glad to hear that, but OP is probably not.
– Poul Bak
Nov 13 '18 at 0:01
From a privacy perspective I'm glad too. From a "getting my intranet system browser compatible" perspective, not so much. I needed support for both pasting into a single field and having tab-delimited data pasting replace multiple fields/lines in a grid. We had a button for the second type of paste in the past, but now I have a workaround overriding the paste event. I'll post an answer with my code.
– Brandon Barkley
Nov 14 '18 at 14:16
From a privacy perspective I'm glad too. From a "getting my intranet system browser compatible" perspective, not so much. I needed support for both pasting into a single field and having tab-delimited data pasting replace multiple fields/lines in a grid. We had a button for the second type of paste in the past, but now I have a workaround overriding the paste event. I'll post an answer with my code.
– Brandon Barkley
Nov 14 '18 at 14:16
1
1
@BrandonBarkley if it's for your intranet can't you simply set up an extension on all the posts? Extensions can access clipboard data with no restriction (when granted the clipboardRead permission). developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/…
– Kaiido
Nov 14 '18 at 14:18
@BrandonBarkley if it's for your intranet can't you simply set up an extension on all the posts? Extensions can access clipboard data with no restriction (when granted the clipboardRead permission). developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/…
– Kaiido
Nov 14 '18 at 14:18
|
show 1 more comment
As Kaiido noted, it is not possible to get at the pasted content outside of the paste event in Edge (and Chrome for that matter).
Users previously used a custom right-click menu to access "Paste From Excel" functionality to replace content in an editable grid with tab-delimited content from the clipboard. If window.clipboardData is undefined the user received a message saying that you must use the standard CTRL+V paste in this browser.
I then added the listener below which essentially determined if the content was tab-delimited and treated it as a "Paste from Excel" whereas it treated other data layouts as a standard "Paste". This was sufficient for my deployment, but for others, it may be worthwhile to launch a confirm window to verify intention.
document.getElementById(myGridID).addEventListener("paste", function(e) {
var clipboardContent = window.clipboardData ? window.clipboardData.getData("Text") : (e.clipboardData ? e.clipboardData.getData("text/plain") : "");
if(clipboardContent != null && clipboardContent.indexOf('t') >= 0)
{
MyExcelPasteFunction(myGridID, clipboardContent);
e.preventDefault();
}
});
add a comment |
As Kaiido noted, it is not possible to get at the pasted content outside of the paste event in Edge (and Chrome for that matter).
Users previously used a custom right-click menu to access "Paste From Excel" functionality to replace content in an editable grid with tab-delimited content from the clipboard. If window.clipboardData is undefined the user received a message saying that you must use the standard CTRL+V paste in this browser.
I then added the listener below which essentially determined if the content was tab-delimited and treated it as a "Paste from Excel" whereas it treated other data layouts as a standard "Paste". This was sufficient for my deployment, but for others, it may be worthwhile to launch a confirm window to verify intention.
document.getElementById(myGridID).addEventListener("paste", function(e) {
var clipboardContent = window.clipboardData ? window.clipboardData.getData("Text") : (e.clipboardData ? e.clipboardData.getData("text/plain") : "");
if(clipboardContent != null && clipboardContent.indexOf('t') >= 0)
{
MyExcelPasteFunction(myGridID, clipboardContent);
e.preventDefault();
}
});
add a comment |
As Kaiido noted, it is not possible to get at the pasted content outside of the paste event in Edge (and Chrome for that matter).
Users previously used a custom right-click menu to access "Paste From Excel" functionality to replace content in an editable grid with tab-delimited content from the clipboard. If window.clipboardData is undefined the user received a message saying that you must use the standard CTRL+V paste in this browser.
I then added the listener below which essentially determined if the content was tab-delimited and treated it as a "Paste from Excel" whereas it treated other data layouts as a standard "Paste". This was sufficient for my deployment, but for others, it may be worthwhile to launch a confirm window to verify intention.
document.getElementById(myGridID).addEventListener("paste", function(e) {
var clipboardContent = window.clipboardData ? window.clipboardData.getData("Text") : (e.clipboardData ? e.clipboardData.getData("text/plain") : "");
if(clipboardContent != null && clipboardContent.indexOf('t') >= 0)
{
MyExcelPasteFunction(myGridID, clipboardContent);
e.preventDefault();
}
});
As Kaiido noted, it is not possible to get at the pasted content outside of the paste event in Edge (and Chrome for that matter).
Users previously used a custom right-click menu to access "Paste From Excel" functionality to replace content in an editable grid with tab-delimited content from the clipboard. If window.clipboardData is undefined the user received a message saying that you must use the standard CTRL+V paste in this browser.
I then added the listener below which essentially determined if the content was tab-delimited and treated it as a "Paste from Excel" whereas it treated other data layouts as a standard "Paste". This was sufficient for my deployment, but for others, it may be worthwhile to launch a confirm window to verify intention.
document.getElementById(myGridID).addEventListener("paste", function(e) {
var clipboardContent = window.clipboardData ? window.clipboardData.getData("Text") : (e.clipboardData ? e.clipboardData.getData("text/plain") : "");
if(clipboardContent != null && clipboardContent.indexOf('t') >= 0)
{
MyExcelPasteFunction(myGridID, clipboardContent);
e.preventDefault();
}
});
answered Nov 14 '18 at 14:29
Brandon Barkley
406312
406312
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271387%2fis-there-an-equivalent-to-window-clipboarddata-in-microsoft-edge%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown