Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > opening a new window with HTML code instead of file

Reply
Thread Tools

opening a new window with HTML code instead of file

 
 
laredotornado@zipmail.com
Guest
Posts: n/a
 
      08-22-2005
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

 
Reply With Quote
 
 
 
 
Csaba Gabor
Guest
Posts: n/a
 
      08-22-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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

 
Reply With Quote
 
 
 
 
laredotornado@zipmail.com
Guest
Posts: n/a
 
      08-23-2005
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

 
Reply With Quote
 
|-|erc
Guest
Posts: n/a
 
      08-23-2005
<(E-Mail Removed)> 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



 
Reply With Quote
 
askMe
Guest
Posts: n/a
 
      08-23-2005

Csaba Gabor wrote:
> (E-Mail Removed) 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


 
Reply With Quote
 
Csaba Gabor
Guest
Posts: n/a
 
      08-23-2005
(E-Mail Removed) 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>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Window.Open get new tab instead of new window in FireFox Fredzidd@gmail.com Javascript 1 02-29-2008 03:06 AM
IE7 opening new window instead of tab Robin Computer Support 5 02-18-2007 05:33 PM
How to tell VS to wite HTML element's styles in the CSS file automaticly instead of in the body of the HTML file. oranmeir@gmail.com ASP .Net 1 06-09-2006 06:53 AM
Opening a new browser window to a specific size without the menu bar and address window. UJ ASP .Net 2 06-27-2005 08:21 PM
Closing child window when opening a new Window Patrick Olurotimi Ige ASP .Net 2 12-14-2004 04:59 AM



Advertisments