# navigator.clipboard.writeText on non SSL (http: as opposed to https:) site

**URL:** <https://discourse.mozilla.org/t/navigator-clipboard-writetext-on-non-ssl-http-as-opposed-to-https-site/38039>\
**Category:** Development\
**Created:** [April 9, 2019, 9:31pm UTC](https://discourse.mozilla.org/t/navigator-clipboard-writetext-on-non-ssl-http-as-opposed-to-https-site/38039 "2019-04-09T21:31:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![msaroff](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/msaroff/32/20303_2.png) [@msaroff](https://discourse.mozilla.org/u/msaroff)\
**Post date:** [April 9, 2019, 9:31pm UTC](https://discourse.mozilla.org/t/navigator-clipboard-writetext-on-non-ssl-http-as-opposed-to-https-site/38039/1 "2019-04-09T21:31:18Z")

</div>

I am looking to use navigator.clipboard.write & navigator.clipboard.read.

I was having some issues, and I realized that it was not working because the site I was trying it on did not use SSL: It was an http:// site, not an https:// site, and so the API was not activated.

Is there a way to activate this on non SSL pages, and if so, what are the ancillary isues, particularly with regard to security, that this would bring up.

All actions on the addon are user initiated, through the context menu, so there is no way that this addon would paste something to, or copy something from a page, without user actions.

---

<div class="post-metadata">

**Author:** ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)\
**Post date:** [April 9, 2019, 10:38pm UTC](https://discourse.mozilla.org/t/navigator-clipboard-writetext-on-non-ssl-http-as-opposed-to-https-site/38039/2 "2019-04-09T22:38:07Z")

</div>

As far as I understand, as long as you have the related clipboard permissions and are calling the functions in your extension contexts and not in a page context they should work just fine.

---

<div class="post-metadata">

**Author:** ![msaroff](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/msaroff/32/20303_2.png) [@msaroff](https://discourse.mozilla.org/u/msaroff)\
**Post date:** [April 10, 2019, 4:10pm UTC](https://discourse.mozilla.org/t/navigator-clipboard-writetext-on-non-ssl-http-as-opposed-to-https-site/38039/3 "2019-04-10T16:10:20Z")

</div>

I’m unclear on how to handle contexts.

I have a web page that can be loaded either with or without SSL, [http://www.panix.com/~msaroff/cntedt.html](http://www.panix.com/~msaroff/cntedt.html) or [https://www.panix.com/~msaroff/cntedt.html](https://www.panix.com/~msaroff/cntedt.html) which gives me use cases to test, and the `document.execCommand('paste')` command only works on the SSL page.

It pasts a string (“blblblblblbl”) over a selection, but it only works on a page with SSL.

Code from the content script below:

```
console.log("Current contents of clipboard",(await readFromClipboard()));
document.execCommand('cut'); //copy to clipboard
let copsel = await readFromClipboard();
console.log("selection copied to clipboard", copsel);
await navigator.clipboard.writeText('blblblblblblblblblblblblblbl'); // this is what appears not to be activating
document.execCommand('paste');
```

---

<div class="post-metadata">

**Author:** ![msaroff](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/msaroff/32/20303_2.png) [@msaroff](https://discourse.mozilla.org/u/msaroff)\
**Post date:** [April 11, 2019, 11:01pm UTC](https://discourse.mozilla.org/t/navigator-clipboard-writetext-on-non-ssl-http-as-opposed-to-https-site/38039/4 "2019-04-11T23:01:09Z")

</div>

It appears that it is both the `navigator.clipboard.writeText` ~~and the document.execCommand(‘paste’)~~ in `http` mode, though they do in `https` mode.

I am wondering if there is a work around.

If not, I end up with some code bloat to accommodate most, but not all, of the cases.

Update, it’s just the `navigator.clipboard.writeText`, `document.execCommand('paste')` works fine.
