I already created an extension that does the following:
When I run Thinderbird with the command line thunderbird -MyCustomParam1 "12345" my extension will open a compose window and add the parameter "12345" to the window.
Some code that I use:
// In the calling code
var args = {
param1: 12345,
};
args.wrappedJSObject = args;
var watcher = Components.classes["#mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher);
watcher.openWindow(null, url, windowName, features, args);
// In the window code
var args = window.arguments[0].wrappedJSObject;
Of course using the correct url and features.
Now I want to do the same, but for the message window and with am eml file that is choose.
You can open an eml file from the command line like this: Thunderbird test.eml (this will open the mail in a new window).
What I want is the following:
Thunderbird test.eml -MycustomParam1 "1234" should open the mail, and add the param "1234" to screen, so I can access it in the document window, just like example 1.
So basically I want something like watcher.openWindow, but with a given eml file.
Any ideas?
You can see how this is done in the MsgOpenFromFile function, it is being called for the File / Open Saved Message menu item. You basically have to take the eml file (get an nsIFile instance from file path), turn it into a URI and then change the query string before opening a message window:
uri.QueryInterface(Components.interfaces.nsIURL);
uri.query = "type=application/x-message-display";
watcher.openWindow(null, "chrome://messenger/content/messageWindow.xul", "_blank",
"all,chrome,dialog=no,status,toolbar", uri);
Related
I'm a noob. I have a code to simulate a terminal. This is it: https://codepen.io/isdampe/pen/YpgOYr.
Command:
var coreCmds = {
"clear": clear
};
Answer (clear the screen):
function clear(argv, argc) {
termBuffer = "";
return "";
}
As mentioned in the title, how to add a command to launch a new tab in the browser (to google.com for example, or anywhere else)?
Thank you.
window.open();
The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values.
Here's an example:
window.open("https://www.google.com");
Structure:
window.open(URL, name, specs, replace)
Since you want to open a new tab in browser, you should put _blank in name. However, this is the default.
What would your code look like?
This is a rough outline, replace variable names and arguments as you like
var var_name = {
"new window": new_window
};
function new_window(arguments) {
termBuffer = "";
return window.open(arguments);
}
I hope this helps :D
Use the window.open method with an input URL.
window.open('https://google.com')
This would open a tab to https://google.com.
I am trying to open new tab using Window Open under javascript as below:
$.ajax({type: "POST",url:"GetData.php?m="+e.series.key,
dataType: "json"}).done
(function( FolderPath )//i get the folder path under this variable
{
OpenInNewTab(url);//url="file://///NetworkSharePath/Folder1/Folder2" -->URL Value
});
function OpenInNewTab(url) {
var win = window.open(url , '_blank');
win.focus();
}
Observation:
It opens a new Tab but not the desired Path.
Note:
I have added Local Links for Chrome as an extension.
When i paste the same url in browser, its able to load the directory structure
When i try to open http://www.google.com, it redirects the new tab correctly.
Not sure what am I missing, please share inputs
I am new to chrome extensions and trying to work this out.
When I click on the extension button, it should copy the current url and open google.com in a new tab then place this url in searchbox or console print the url. Basically,
Copy the url to new tab, which can be used to perform further actions.
We can open new tab using.
chrome.browserAction.onClicked.addListener(function(tab) {
var action_url = "http://www.google.com"
chrome.tabs.create({ url: action_url });
});
Not sure how to call functions/perform actions after the new tab openx
You want to do two things :
1) Copy the current url.
2) Do something with it in the new tab opened with google.com as the url.
You can get the current url in javascript using: window.location.href
You have a callback function for chrome.tabs.create(object createProperties, function callback) as here and use this callback function ( which is called once the tab is successfully created) to pass current url to content script using message passing.
copy the current url using ** window.location.href**
make a new string by concating the string obtained in step 1 with https://www.google.co.in/search?q= i.e new string would be https://www.google.co.in/search?q=www.google.com (if you want to search google.com in new tab)
write a javascript function in content script to open new tab and search for the string obtained in step 2.
I want to open webpage and automatically fill in login information. My main.js addon code is given below. I have uname and upass variable. I want to fill in the login form using those when addon opens the tab.
var uname="username";
var upass="password";
tabs.open({
url: "https://www.facebook.com",
onReady:runScript
});
function runScript(tab) {
tab.attach({
contentScriptFile: data.url("mody.js")
});
I put this code in my mody.js file:
document.getElementById("email").value=uname; // uname undefined
document.getElementById("pass").value=upass; // upass undefined
But I can't access these variables from mody.js. Is there any way to pass this variable to the login page?
Use the contentScriptOptions for this.
The contentScriptOptions is a JSON object that is exposed to content
scripts as a read-only value under the self.options property:
I am writing code to download a PDF file using window.open(). I am passing the URL path of the pdf file on a server.
window.open(url, name, "width=910,height=750,scrollbars=yes");
I want to check if the downloading of file is successful or not. What is the return type of window.open()?
I tried like this
try
{
window.open(url, name, "width=910,height=750,scrollbars=yes");
alert("success");
}
catch(e)
{
alert("failer");
}
When I change the URL to a wrong URL, it shows the same result as a success.
http://www.javascripter.net/faq/openinga.htm
The return value is the reference to your new window. You can use
this reference later, for example, to close this window
(winRef.close()), give focus to the window (winRef.focus()) or perform
other window manipulations.
Window.open either returns a handle to the new window opened or null, it will not tell you if the page within the window loaded successfully. If you where opening an html page (from the same domain) you could use this to look into the document
var newWin = window.open();
if(newWin == null) {
alert("darn");
}
newWin.document.getElementById("anElement").innerText = "Fish";