Open Popup Window

Hi,

I want to open Popwindow, in center using button click.

var buttons = require('sdk/ui/button/action');
var button = buttons.ActionButton({
	id: "My-Button",
	label: "My Button",
	icon: {
		"16": "./16x16.png"
	},
	onClick: handleClick
});

function handleClick(state) {	
	var { openDialog } = require('sdk/window/utils');
	var window = openDialog({
		url: "http://www.google.com",
		name: 'MyWindow',
		features: 'width=600,height=650,center, minimize=true'
	});	
}

I am using above code and its opening Popup window, but the window does not has “minimize button” as well as it does not open in Center"

Could you please help me with it?

Regards
Ashish Sapkale

You should check this out for the features you can specify:
https://developer.mozilla.org/en-US/docs/Web/API/Window/open

What you are looking for is the minimizable property or dialog=false.
The documentations speaks of “yes” and “no”, this should be “true” and “false”.

For centering, I think you need to look at the top and left properties.

Sorry,

I forgot to mention

I am trying to open Window from Add-on.

Have you tried ‘centerscreen’ instead of ‘center’?

Still, those are the features you can specify for the sdk as well.

Thanks MartijnJ and erosman,

features: ‘width=600,height=650,center, left=50, top=50, minimizable=yes, chrome=yes, centerscreen=yes’

This feature worked for me. :smile:

Just wanted to confirm, are there any new updates with Firefox 41?

Because “browser.newtab.url” is missing in preferenes :frowning:

Thanks again for your help…

It has been replaced with

const NewTabURL = require('resource:///modules/NewTabURL.jsm').NewTabURL;
NewTabURL.override(preferences.prefs['url'] || 'about:newtab');

Look here:
New Tab Override (browser.newtab.url replacement)

For people looking how to do it the non-sdk way: http://forums.mozillazine.org/viewtopic.php?f=19&t=2777483&hilit=+proper