How to run a local bat file on a js button click using Chrome browser ?
'window.open('file:///C:/Test/Test.bat' - Opens the bat file contents in a new tab instead of executing the file. It works fine in IE browser. Please suggest how to achieve this in chrome without using any plugins.
You can't do that.
Otherwise it would be a security problems because hackers could use it to do malicious things on our computer.
I have strange problem on Chrome for Android with local website.
It works perfect on Firefox for Andorid, but not for Chrome.
On my site here: https://passcombo.com there is download link with a zip file.
What I do is:
download file to local file system (not SSD! - external storage makes
another problem!)
I unzip the package and go to the site in local storage using File Commander
I open the html file with Chrome - only HTML loads, no CSS, no JS, no images, no fonts.
Looks like there is path problem with relative paths?
But firefox works!
Working alternative is Firefox, but there you need to write correct strange path: "file:///storage/emulated/0/..../...html"
But...
Currently Chrome is mostly used on Andorid so it's bad local sites not working :/
It doesn't work opening with file explorer, you have to write the path in the address bar file:///sdcard/Download... or wherever.
JS works with Chrome on local html file in my Galaxy S6.
The only solution I found is to:
[update 2021] use Opera (Firefox did work before recent update!)
copy folder with my html/css/js to local storage
(somewhere)
open the sitewith path like:
[current Opera] file:///storage/0000-0000/MyFolder/index.html
[old in firefox ] file:///storage/emulated/0/myfolder/index.html
where 'file:///storage/0000-0000/' OR 'file:///storage/emulated/0/' is the main path to local storage, and if you copied your folder somehwre deeper then you need to change the 'myfolder' to /somefolder1/somesubfolder/.../ sth
Shame it's the only way to create a web browser app for adroid.
It is possible using a HTTP server app on your phone.
For example the SimpleHttpServer.
Set the "Document Root" in the settings of that app to the folder in which your html files reside. Start the server and you will see a local link.
Click on that link and choose the html file you want to show.
If you declared your assets relatively those assets will loaded, too.
Seems like the only directory Chrome reads local files from is file:///sdcard/Android/data/com.android.chrome/files/Download/
The only solution worked for me in Android is the HTTP Web Server (I used Simple HTTP Server).
Installing different browsers didn't help:
(Apr-2021) I tried installing various Browsers (Chrome, FireFox, even Opera etc.) in Android but none worked. In all cases, when I navigated to the folder containing HTML/JS files using local file:/// URLs ('file:///sdcard/' or 'file:///storage/emulated/0/') browsers only displayed the folders but no files.
When I used the absolute path to the HTML file the browsers used content:/// protocol to
render static HTML content, i.e. it did NOT allow execution of JavaScript code.
In my Android OS version 7, to open a local html file with css and javascript in Google Chrome browser (ver. 64.0.3282.123) I have to open it through an address bar typing as file://localhost/sdcard/, then navigating to the file location. In spite of mention sdcard in the address, it opens an internal storage (and my device has actual removable sdcard as well).
Currently, I am also facing this problem. Chrome does not link to other files on the device, but you can use js and CSS by, using <script> and <style> tags and these will be included in the web page. But, for other files, like image, audio, videos, etc. it can't be done on Android still without any server established by 3rd party apps.
Install a text editor from playstore . Its name Acode
Got to your local file storage , then choose your .html file and press long time.
After press long time on .html file , you will see more (left side of your phone screen)
From more menu, chose open with option
Choose Acode text editor
When html file open on Acode editor, then preview it from Acode text editor.
that's all. It will works 100%.. (sorry for my english)
I read the documentation of SDK add-on development for firefox.
I have my add-on for chrome just built.I'm not sure of the terminology in firefox development.
My files for my chrome extension:
popup.html, popup.js, popup.css, icon.png - files which deal with the pageaction popup in chrome
contenscript.js -- which injects code into a page
background.js - a background script for the extension
manifest.json
1)So, what are the counter-parts for these files in firefox ?and , it seems firefox develpoment folder has
data
doc
lib
test
readme.md
2)Do I need to use all of them ? What files go into what?
Lib: This is where you usually put your main addon code. By default, ./lib/main.js is your entry point to the addon.
Data: This is where you put content scripts. Content scripts function like running in a different environment and can communicate with your main addon code via message passing. Content scripts can be attached to a page (Page-Mod), in its own environment to perform a process or action (PageWorker), or be its own content (like a Panel).
Doc and Test are for documentation and tests; not necessary.
To translate it to chrome extensions, all of your pop-up code (js/css/html/png) would live in the ./data directory. Your main addon code would create a Panel (if I understand Chrome's "popups" correctly), and reference the code in data.
background.js IIRC is just a script that performs some process. Maybe some JS that performs some heavy-duty operation or is constantly scraping an API for updates, and runs independently of what tab is open. The SDK equivalent of that would be a PageWorker.
manifest.json is just the package.json.
Both panel and pageworkers use content scripts; for more info, guides on working with content scripts
I have just uploaded a wordpress site from previously developing it on my localhost. On my localhost there are several plugin javascript files that are picked up and used to display a tooltip on the google map plugin for the markers.
On my localhost this all works fine but when i uploaded this through FTP, some of the javascript files appear to longer be loaded. Is there any way to check which files are being uploaded when the page is loading the javascript?
Whenever i try to check or edit the file from Filezilla, it gives a Microsoft JScript runtime error, Code: 800A1391, Error: 'document' is undefined, so i can't check that what the host uses is the exact same code as my localhost.
Many thanks,
Dan
Most browser developer toolkits (Dragonfly, Chrome Developer Tools, Firebug, etc) include a Net tab which will tell you which files have been requested and the status of them.
Try using either firebug http://getfirebug.com/ with Firefox or the Chrome web inspector and look at the (Net/Network) panel while you reload the page to see if the js files are trying to load. This should give you some insight.
I am new to extension programming but find making extensions in Chrome much more easier, but now that I am trying to port my test extensions to FF I have a few questions of how to do the same things I do in Chrome... now in FF.
For example:
In Chrome I have a page in my extensions directory called: domains.html
I link to that page from my popup and it has access to all my scripts etc but the "outside" world cannot directly access that.
Is there any such thing in FF so that I can show a page that is in my add on folder and has access to my add-on's JS and other files?
Thanks!
Take a look at some of the docs for opening URLs in new Tabs and manipulating the content of the tab:
https://developer.mozilla.org/en/Code_snippets/Tabbed_browser#Opening_a_URL_in_a_new_tab
Once you get comfortable with that, try opening an HTML page that lives in your add-on. First, you need to be aware of the 'content' package name you registered in your chrome.manifest file. Second, make sure your 'domains.html' file is in the content folder of your add-on. To open the web page in a new tab using a button or menu in Firefox use code like this:
gBrowser.addTab("chrome://mypackagename/content/domains.html");
You can should be able to load other JS and CSS files from your add-on into the web page using similar chrome:// URIs.