By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,490 Members | 1,292 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,490 IT Pros & Developers. It's quick & easy.

opening a new window with HTML code instead of file

P: n/a
Hello,
I am searching for a cross-browser way (the most recent browsers
are fine) to use javascript to open a new window even though I do not
know the file I want to call. I do, however, know the HTML code I want
output in the new window. It would look like

<HTML>
<HEAD><TITLE>Hello</TITLE>
</HEAD>
<BODY>
Hello
</BODY>
</HTML>

I understand I could put this text into a file and call that, but if
there were a way to automatically populate the window with this code,
prior to opening it, that would be the ideal.

Thanks, - Dave

Aug 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
la***********@zipmail.com wrote:
Hello,
I am searching for a cross-browser way (the most recent browsers
are fine) to use javascript to open a new window even though I do not
know the file I want to call. I do, however, know the HTML code I want
output in the new window. It would look like


var newWin = window.open("about:blank");
newWin.document.open();
newWin.document.write("<body>Some text</body>");
newWin.document.close();
newWin.document.title = "My favorite title";

See also perhaps the recent discussion at:
http://groups.google.co.uk/group/com...60664279d6460/

Csaba Gabor from Vienna

Aug 22 '05 #2

P: n/a
Thanks but sadly when I try this code on PC IE 6.0, I get a javascript
error that says "Access Denied".

Is there another way?

- Dave

Aug 23 '05 #3

P: n/a
<la***********@zipmail.com> wrote in
Thanks but sadly when I try this code on PC IE 6.0, I get a javascript
error that says "Access Denied".

Is there another way?


http://www.htmlgoodies.com/primers/j...le.php/3478241

that any better?

Herc
--
too intelligent
See - you do get intelligent people on here! Kay. Well, there's you
and me and Herc.... the rest are a bit sus though
Dave Budd ~ UK Mensa founder

Aug 23 '05 #4

P: n/a

Csaba Gabor wrote:
la***********@zipmail.com wrote:
Hello,
I am searching for a cross-browser way (the most recent browsers
are fine) to use javascript to open a new window even though I do not
know the file I want to call. I do, however, know the HTML code I want
output in the new window. It would look like


You would have to change the "about:blank" to a "/" or something to get
the address bar to look right.

function javascripttest()
{
var newWin = window.open("/");
newWin.document.open();
newWin.document.write("<body>My virtual web page <BR> is what you
see!</body>");
newWin.document.title = "My virtual title";
newWin.document.close();
return;
}

http://www.askblax.com
var newWin = window.open("about:blank");
newWin.document.open();
newWin.document.write("<body>Some text</body>");
newWin.document.close();
newWin.document.title = "My favorite title";

See also perhaps the recent discussion at:
http://groups.google.co.uk/group/com...60664279d6460/

Csaba Gabor from Vienna


Aug 23 '05 #5

P: n/a
la***********@zipmail.com wrote:
Thanks but sadly when I try this code on PC IE 6.0, I get a javascript
error that says "Access Denied".


The popup blocker's stance is that it will only put up a popup on a
user initiated action. That means things like clicking on buttons,
etc. Unfortunately, IE/FF will not respond to popup attempts as a
result of a keyboard listener (document.onkeyup = function() {...} )
even though it's pretty clear that pressing a ctrl+key is not an
accidental user action.

The code below now includes a button you may press.
Csaba Gabor
<button onclick="dome()" accesskey=d><u>D</u>o me
<script type='text/javascript'>
function dome() {
var newWin = window.open("about:blank");
newWin.document.open();
newWin.document.write("<body>Some text</body>");
newWin.document.close();
newWin.document.title = "My favorite title";
}
</script>

Aug 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.