I don't know much about JavaScript. I am trying to open a tab with a file URL and it keeps reverting to the about:newtab page. Is it possible to open a file URL in Firefox extension?
Currently I am using:
var updating = browser.tabs.update(tab.id, { url: result.data.url });
updating.then(onUpdated, onError);
Where result.data.url is a file URL. It works with HTTP and HTTPS URL.
I am using Firefox 56.0.1
Currently it's not possible. You can follow bug https://bugzilla.mozilla.org/show_bug.cgi?id=1266960 to stay up to date.
Related
I'm trying to use window.open to open an extension page, I don't care about checking if the user has the extension, I just want to open a window that starts with extension://, it's not working and says failed to load url because the scheme does not have a registered handler. My code looks like this:
const openedWindow = window.open("extension://<extension url>", "", "width=300, height=300");
openedWindow.onload = () => {
openedWindow.close();
}
this code works with normal urls, but not with ones starting with extension://. Is there any way to open a url like this?
edit: needed to use chrome-extension:// instead of just extension. Now there's a new problem, chrome is blocking the page. How do I fix this?
It's because the correct URL for a chrome extension is chrome-extension://1234
Also popups should be explicitly allowed by a user interaction on the popup permission that Chrome asks in the URL bar
i´m currently using JavaScript and HTML with eel and Python. But unfortunately when I am trying to create a file in the Chrome-Browser window (as an download) over JS i can only download it once.
The second "download" is not working.
-> Chrome just shows this (as it does when it downloads something) but then nothing happens:
When I am using Edge browser or only JS without eel it works perfectly fine!
My JS function that creates the download: (string is a json string that is generated earlier).
var jsonLink = document.getElementById("jsonLink");
jsonLink.download = "exportedToJson.json";
jsonLink.href = "data:application/json;charset=utf-8," + encodeURIComponent(string);
Ok I found a solution:
My chrome browser was blocking more than one download from "localhost:8000". So I had to go to settings and allow more than one download.
Maybe this helps someone :)
Why did I not find this earlier:
When I started my Python script, it calls:
eel.start('index.html', mode='chrome', port=8000) #starting chrome
Which does open a new Chrome Tab without the Tabbar (so i did neither see the tabs nor my favorite sites). Therefore I did not get a notification when chrome stated that download is blocked.
But after starting the eel-local webserver and open localhost:8000 in my normal chrome window, I did get a notification and I was able to allow the downloads.
-> afterwards it also worked in this eel-chrome window.
Hi I've got follow json:
let help = {
url: 'file://myServer/folder1/myFile.pdf'
};
With this function I try to open the file in a browser:
openPdf() {
window.open(help.url);
}
This is my html:
<button ng-click="ctrl.openPdf()">Open PDF</button>
Now, when I click on the button, a new tab opens in the browser without the pdf file. There isn't also my url from the json. It opens a empty page - about:blank. But when I copy the url from the json and paste it again in the browser, it opens the file correctly. But this also works only, when I put file:// before the url (without this, or with http:// etc. it also doesn't work) - Browser = Google Chrome. The confusing thing is: It works on Internet Explorer! When I open the url (with file://), than it shows me the pdf in a new browser tab. Is there perhaps a pdf plugin for browser, that isn't installed on chrome? Any ideas what could be wrong here? Thanks
chrome.runtime.onInstalled.addListener(function(){
chrome.tabs.update(null, {url: ''});
alert();
});
Above code doesn't work when I install my extension in developer mode. I want to update the active tab to be a blank tab once my extension installed in chrome web store.
That's an invalid URL, that's why it does not work.
You can't just "erase" the URL without navigating to what you supply as the new URL.
If you are trying to navigate to the New Tab page, it has a URL (that's normally hidden) chrome://newtab. If you want a blank page in terms of content, it's about:blank.
Is it possible via window.open to open a page with information about the version of the browser? My browser is Google Chrome.
window.open("chrome://version/");
This code opens a new tab "about:blank".
You cannot use any of the usual APIs from the Web platform to open chrome:// pages.
These pages can be opened using chrome.tabs.create though:
chrome.tabs.create({
url: 'chrome://version'
});
You're not allowed to do this (security reason, probably):
Try typing that in the console:
window.location.href = "chrome://version/"
output: Not allowed to load local resource: chrome://version/