How to open a file by tabs.create()

links : https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/create

say that on the page
‘file: URLs (i.e., files on the filesystem. However, to use a file packaged inside the extension, see below)’
but where is the below

It’s below that block:

2 Likes

we open a new tab to ‘https://www.mozilla.org/’ below;
browser.tabs.create({
url: ‘https://www.mozilla.org/
});
//----------------------------------------------------------------------------------
what should do to open a pdf file like ‘c:\1.pdf’ or ‘d:\1.pdf’ or ‘e:\1.pdf’;

It do not work like below;
browser.tabs.create({
url: ‘c:\1.pdf’
});

As the documentation says, you can’t access files on the file system, only the files supplied by the extension.
There is a workaround for a similar case, but I’m not sure it applies here as well. Also it needs to be done in end-user browser:

thanks a lot anyway,it maybe not work for firefox extensions,i will look for other ways and try ;