djp1988 Posted July 10, 2009 Share Posted July 10, 2009 Hi, can I send an ajax response to a new window I created with window.open() ? Link to comment Share on other sites More sharing options...
jesh Posted July 10, 2009 Share Posted July 10, 2009 Yep. var win = window.open();win.document.open();win.document.write("<html><body><h1>THIS COULD BE AN AJAX RESPONSE!</h1></body></html>");win.document.close(); Link to comment Share on other sites More sharing options...
djp1988 Posted July 10, 2009 Author Share Posted July 10, 2009 cheers Link to comment Share on other sites More sharing options...
djp1988 Posted July 10, 2009 Author Share Posted July 10, 2009 Hi again, I have another question, I'm using this window to preview some text as user content before the user submits it.so when i press preview, i get the popup window... But If I go back to the page where i typed the info without closing the pop up, and i click the preview button again, the pop up as it is already an existing window, is refreshed with the new content but it doesn't come back to the front, so the user could "loose" the window, which can be annoying, either I should close the window onblur, but i couldn't get this to work, or and better solution, just always bring the window to the front, but how can i do that? is there an attribute to set the order the window is in the stack of windows? Link to comment Share on other sites More sharing options...
jesh Posted July 10, 2009 Share Posted July 10, 2009 If you opened the window like so: var win = window.open(); Then you can bring that window to focus at any time later in your code using the following: win.focus(); EDIT: Check out the HTML DOM tutorial for more information about what you can do with the window object:http://www.w3schools.com/htmldom/dom_obj_window.asp Link to comment Share on other sites More sharing options...
djp1988 Posted July 11, 2009 Author Share Posted July 11, 2009 win.focud() works on safari 4Doesn't on firefox 3.5, or Opera both on macThis is my code: xmlHttpText.onreadystatechange=function(){ if (xmlHttpText.readyState==4){ var win = window.open('page.php','win','width=850,height=600,scrollbars=1'); win.focus(); win.document.open(); win.document.write("<html><body>"+xmlHttpText.responseText+"</body></html>"); win.document.close(); } }; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.