> What T.J. sugested, was that I open a blank new window and use a ajax
> request to get the result(HTML) of the page I was previously opening
> and then put that result on the blank page.
Well, almost. I suggested that one approach might be to open a
window, use an Ajax.Request to load content, and write that content to
the window. I didn't mean to suggest that you wouldn't need to modify
the page coming back; in fact I mentioned you probably *would* need to
change it because it'll need to return a snippet of HTML (the content
of the body) rather than a full page with the example I was giving
you.
We can probably use your page unaltered though, by falling back on the
venerable document.write method. (Ducks as the group recoils with
gasps of shock and horror.) Also, we don't have to load the "loading"
page from the server, we can still avoid that round-trip:
* * * *
var wnd;
wnd = window.open('', '_blank', 'height=400');
wnd.document.open();
wnd.document.write(
"<html>" +
"<head>" +
"<title>Loading</title>" +
"<link rel='stylesheet' href='style.css' type='text/css'
media='screen' />" +
"</head>" +
"<body>" +
"<p>Loading...</p>" +
"</body>" +
"</html>");
wnd.document.close();
new Ajax.Request('test.jsp', {
onSuccess: function(transport) {
wnd.document.open();
wnd.document.write(transport.responseText);
wnd.document.close();
}
});
* * * *
This has the advantage that the "loading" window appears immediately.
Alternately, of course, you _can_ load a static file for the "loading"
page and use a callback from the loaded window as Darrin mentioned.
The success handler in the Ajax.Request would still be pretty much
like the above.
I've tested the above in IE6, FF3, Safari for Windows 3.1.1 (and then
3.1.2), and Opera 9.1. They all worked, except that Safari has an
issue that I think is a bug in Safari: It left the window title as
"Untitled" despite the fact that it is recognising the head element
and the link element within it (the text is styled correctly).
A side-effect I can think of is that the window isn't associated with
the URL that the content came from, since all of the content in the
window was generated by script.
Anyway, that should get you going.
On a side point: Are you _sure_ you want to open a new window? These
days it'll have to be opened within the event handler of a user action
(e.g., mouse click), and even then it's not at all guaranteed that the
browser / popup blocker will allow it...
Hope this helps,
--
T.J. Crowder
tj / crowder software / com