Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   opening a new window with HTML code instead of file (http://www.velocityreviews.com/forums/t919800-opening-a-new-window-with-html-code-instead-of-file.html)

laredotornado@zipmail.com 08-22-2005 02:31 PM

opening a new window with HTML code instead of file
 
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


Csaba Gabor 08-22-2005 04:08 PM

Re: opening a new window with HTML code instead of file
 
laredotornado@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


laredotornado@zipmail.com 08-23-2005 12:19 AM

Re: opening a new window with HTML code instead of file
 
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


|-|erc 08-23-2005 06:29 AM

Re: opening a new window with HTML code instead of file
 
<laredotornado@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




askMe 08-23-2005 08:59 AM

Re: opening a new window with HTML code instead of file
 

Csaba Gabor wrote:
> laredotornado@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



Csaba Gabor 08-23-2005 10:08 AM

Re: opening a new window with HTML code instead of file
 
laredotornado@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>



All times are GMT. The time now is 11:11 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.