Simple Simon
Simple Simon

Reputation: 722

Launching widgets using html / javascript

I have created a simple webpage that launches a widget after a button is pressed. The button press adds an element to the DOM tree:

var div = document.getElementById("loginWidget");
var loginWidget = document.createElement('script');
loginWidget.setAttribute("type", "text/javascript");
loginWidget.setAttribute("src", "http://widgetstore.etc.etc");

div.appendChild(loginWidget);

This launches the login widget in the webpage. How do I get it to open in a new window (preferably resized to the size of the widget? If I do it like this will my original window be able to access values from the login widget? If this is a bad idea what's the best way to style the widget so it stands out more from the original size.

Forgive my n00bness. Would normally research this myself but in a bit of a hurry!

Upvotes: 0

Views: 97

Answers (1)

Viktor S.
Viktor S.

Reputation: 12815

Take a look at window.open. It will return a pointer to newly opened window. And you can specify a width and height of that window. But note that you must call window.open in onclick handler. Otherwise, if you will call it in your script block it will be blocked by browser. Also, from widget window you can access initial window using window.parent.

Upvotes: 1

Related Questions