Forum Discussion
Uncaught ReferenceError: ClipboardItem is not defined
- 1 year ago
I think the thread can be closed. MS fixed it. Thanks
It's a bug in the powerbi script. It should check if ClipboardItem is available because it isn't always there. Microsoft forgot to put it inside a try/catch clause. ClipboardItem is not defined when:
- http:// is used in chromium without localhost- cross-origin iframes (when you load powerbi using the javascript client api)
Another solution for MS is to put this code at the start of the injected iframe to mock the clipboard:
if (typeof ClipboardItem == 'undefined') {
ClipboardItem = window.ClipboardItem = function (items) {
return items;
};
}
This is not possible to do yourself when you are embedding Powerbi inside your own website. That is because the cross-origin settings do not allow injecting javascript in the iframe. So I'm not able to produce a workaround for that situation.
It's only possible when using playwright:
await context.addInitScript(`
if (typeof ClipboardItem == 'undefined') {
ClipboardItem = window.ClipboardItem = function (items) {
return items;
};
}
`);
- niyas72041 year agoRegular Visitor
Can we modify the Power BI client script, host it ourselves, and use it as a package?
- PowerrrRon1 year agoNew Member
No that won't work. The PBI client javascript injects an iframe to the document. And the problem is -inside- the iframe. The outer document does not execute the script that is throwing the error, that one is only executed inside the iframe.
- vinpel1 year agoRegular Visitor
If you are using this inside https the issue is no longer throwing up, which is a temporary workaround as per Microsoft