Jump to content
Sign in to follow this  
djp1988

Send Ajax Response To Another Window

Recommended Posts

Hi, can I send an ajax response to a new window I created with window.open() ?

Share this post


Link to post
Share on other sites

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();

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Edited by jesh

Share this post


Link to post
Share on other sites
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();			}		};

Edited by djp

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...