Reputation: 1695
I want to open preview window with ability to confirm it, so I want to use window.open() and append some checkbox at bottom of document. I think it should be something like
var w = window.open("http://mypage.aspx", "_parent", "width=800,height=800");
w.document.write("<input type='checkbox' id='IsConfirmed' />");
but this code is not working... It doesn't load content of http://mypage.aspx
.
So the question is how to load content of "http://mypage.aspx" and append checkbox at bottom of page?
Thanks in advance!
Upvotes: 0
Views: 8431
Reputation: 440
http://mypage.aspx looks wrong... where's the hostname?
ok.. even if that request is valid.. the moment the request is fulfilled, the variable w is no longer available i think... You are on a different page and the javascript variables don't persist through a location change i think..
Upvotes: 0
Reputation: 15711
Considering that http://mypage.aspx
is a valid page path, it will take time to load so playing with the document right at the start might not be a good idea. It could also be why it does not seem to get loaded.
var w = window.open("http://mypage.aspx", "_parent", "width=800,height=800");
w.onload = function(){this.document.body.innerHTML+="<input type='checkbox' id='IsConfirmed' />";};
Using onload on the window will make sure that you are appending the checkbox after the page has been fully loaded... This will prevent some errors.
Upvotes: 1