I’m using the following code to open a blank window from a “secure” page:
$('#previewTemplate').click(function () {
var preview = window.open('', 'PreviewTemplate', 'width=800,height=400,scrollbars=1');
var html = '<html><head><title>Preview</title></head><body>' + $("#textbox").val() + '</body></html>';
preview.document.open("text/html", "replace"); preview.document.write(html); preview.document.close(); return false;
});
The blank window is opening as a secure page (preview.document.location.protocol=”https:”) so IE is barking about the mixed content because I have a non-secure image in the page. I’m trying to open up the blank window as a non-secure window. Trying to change the location.protocol to “http:” or location.port to 80 doesn’t seem to work. Is it possible to open up a blank “non-secure” window from within a secure page?
If the main window was https and the child window was http, the same origin policy would prevent the two from communicating with each other. i.e. those calls to preview.document.open would never work.
Three options:
domain as the parent window.
the same server as the image. Even
if you can only put static html there
for whatever reason, some basic
javascript could be used to read the
url’s query string and get the value
of textbox.
in more modern browsers though.