I'm making a browser extension and I have a credentialManager.html file that I want to open in a new window. Currently doing this
var credentialWindow = window.open("credentialManager.html",
"Credential Manager", "width=150,height=250")
but it just appends credentialManager.html onto whatever website domain I'm on and opens that. I want it to open the file with that name, which is in the extension package. Thoughts?
Found the solution: to access a .html file in the extension package you use the following
var credentialWindow = window.open("ms-browser-extension://[id of extension]/[name of html file].html", "[name your popup window]", "width=[some num],height=[some num]");
Related
I've a shared directory reachable by html page in this way
<div onclick="windows.open('file://mypath/mysharefolder','_blank');">Shared folder</div>
This works with internet explorer, but not with Chrome browser (error: Not allowed to load local resource).
So I've thought of replacing the link with a tag to allow the download of a lnk file (created manually) containing the path of the shared directory like this
<a href="mylinktofolder.lnk" download>Shared folder</a>
this tag works to download other kind of file (img,pdf,...), but not with lnk file; download in Chrome fails because doesn't find file mylinktofolder.download.
Is it possible to download such a file?
Thanks in advance
Chrome marks .lnk files as unsafe for download so you won't be able to workaround this using html/js unfortunately
Sources:
https://stackoverflow.com/questions/55177641/lnk-file-downloading-as-download-in-chrome-and-it-failed-to-download-in-first\
https://stackoverflow.com/a/34890432/2491027
Is it possible to download such a file?
Yes, sort off, here I show two tabs but the second is as you described a shared folder that was opened as second tab, however, has been torn off to show the two types of links in the first index.html
So to answer your question the second link tested with a range of LNK files lastly to a cmd.exe.lnk and onclick triggers a lnk download but as normal for windows the .lnk extension is not shown as actioned, so if the lnk is
a file like svg.lnk it will open the linked svg in the second tab.
a lnk to a folder it will open the folder
a lnk to a command it in turn forces cmd.exe to be downloaded with a warning
and you can accept (keep) and run that copy of cmd !
All the above is possible using Chrome based browsers such as Edge or SlimJet or Ungoogled Chrome. and Chrome too.
<div onclick="window.open('file://c:/mysharedfolder','_blank');">Shared folder</div>
<div onclick="window.open('file://C:/myshortcuts/downloads.lnk','_blank');">downloads.lnk</div>
.
As non admin user I can navigate to local shares or remoteshares or remote mapped drives without any authorisation, other than I have user read write permission for all those locations.
<div onclick="window.open('file://C:/TEMP/HTA/share(local).lnk','_blank');">Local Shared folder</div>
I am new using Phantomjs, and I got the content from a website that I want. Now I want to pass the content into my website (http://test123.com). So what I want to do is, I want to open my website into a new tab in browser. However, I put the code below to test.js file and call it using phantomjs test.js but it didnt work.
var win = window.open("http://test123.com");
Anyone know how can I open a new tab in a browser using phantomjs? what should I put in my .js file ?
Try the following:
var win = window.open("http://test123.com", "_blank");
I have a task that needs to automatically download a file once the user click the button “ok”. I don't have access on the database or source code on the website, just view site access only. I don't know where and how to create it for me to start working on it. I been trying to do it using windows form but I'm not sure if its possible since the application is in the website.
How I can start doing this automatic download without any access on the applications code?
You can use the System.Net.WebClient to download a file from the web.
However you should find a pattern in the file uri.
Here is a sample:
var FileDownload = "http://addressforthefile.pdf";
var FileSaveLocation = #"C:\Downloads\myfile.pdf";
var WebClient = new System.Net.WebClient();
WebClient.DownloadFile(FileDownload, FileSaveLocation);
I currently have a desktop App built with Node Webkit. When the user is online, the App will open up PDF files from the server. I then save these files locally so they are available when offline.
I am using the Node.js File System's fs.writeFile(), to save the PDF locally but when trying to open it via the App the PDF is blank. When I try to open it direct from the folder I get the below error.
Can anyone please advise?
//save PDF file for offline
function saveFile(pdfvar) {
var filename = 'test.pdf';
fs.writeFile(filename, pdfvar);
}
//open PDF in new window
$('#stage').on('click', '#pdflink', function(event){
var pdfvar = (this.getAttribute('data-pdffile'));
window.open(pdfvar, "_blank");
if(online===true){
saveFile(pdfvar);
}
});
Are you holding entire content of a PDF in a DOM element attribute this.getAttribute('data-pdffile') ? This is where it may get corrupted.
When you call
window.open(pdfvar, "_blank");
the content is not ready to be opened like that. It should be first converted to base64 encoded url.
window.open('data:application/pdf,' + escape(pdfvar));
UPDATE:
The actual problem was that the OP was trying to save the file using it's URL in "pdfvar"
fs.writeFile(filename, pdfvar);
but the file created was containing only a URL itself. What was required was downloading the file first using a http library:
How to download a file with Node.js (without using third-party libraries)?
I am building an windows app using Tide SDK. How can I open a local file from my app. For example, I have a pdf file somewhere in my harddisk. I put the link to that file to my app. When I click on the link, I want it to open the pdf file using default programm associated with pdf type file.
If it is not possible then I have one more general question. Is it possible to access local file system by any app that built using html5 and javascript?
we can access local file system in tidesdk application.
See the following code.
var contents;
var file= 'test.txt';
var Dir = Ti.Filesystem.getUserDirectory();
var readfi= Ti.Filesystem.getFile(Dir, file);
if (readfi.exists())
{
var Stream = Ti.Filesystem.getFileStream(readFi);
Stream.open(Ti.Filesystem.MODE_READ);
contents =Stream.read();
alert( contents );
Stream.close();
}
The above code will read the text file and alert the content. Visit here to know tidesdk file system.
Following code will open the given URL in default browser.
Ti.Platform.openURL('http://stackoverflow.com');
Following code will Open the given application or file in the system's default program.
Ti.Platform.openApplication('C:/Documents and Settings/Thavamani00/Desktop/readme.txt');
Ti.Platform.openApplication('C:/Documents and Settings/Thavamani00/Desktop/cart15.png');
The above code displays the text file in notepad and displays the image in mircosoft picture manager.
it works well for me.i hope its your required answer.