10 weber Posted May 11, 2010 Share Posted May 11, 2010 I used the following code. The window opens, and the button exists, but clicking it doesn't work. function winOpen(stAction, stName) { var win = window.open("", "", "width=200, height=200"); win.document.write("<button onclick='java script:win." + stAction + ";'>" + stName + "</button>"); //I tried with and without "win." at the onclick event.}...<button onclick="winOpen('close()', 'close')">open and close</button> (I didn't forget the script, html, body,... tags) Link to comment Share on other sites More sharing options...
ShadowMage Posted May 11, 2010 Share Posted May 11, 2010 win is a variable visible only to the document that opened the new window. The new window you opened doesn't have access to it. You can just use window.close() and that will close the window from which close() was called.win.document.write("<button onclick='java script:window." + stAction + ";'>" + stName + "</button>");this.close() should also work. Scratch that. That won't work. In this situation this would be referring to the button, not the window. Link to comment Share on other sites More sharing options...
10 weber Posted May 11, 2010 Author Share Posted May 11, 2010 It works now, thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.