PC Review


Reply
Thread Tools Rate Thread

Closing a window and printing the contents of a window without Javascript?

 
 
David Broughton
Guest
Posts: n/a
 
      27th Jun 2005
Hi - I am a very occasional Front Page 2002 user.

I am trying to add a page to my JavaScript-free website that will have a
table of information (no problem there) and two buttons - one that says
close and will close the window, and one that says print and will print out
the contents of the window. The page is opened in a new window using the
"_blank" target frame hyperlink option.

A search of this newsgroup and other sources found many examples that use
JavaScript to close a window - i.e.:
<input type="button" value="Close Order Form" onclick="window.opener = self;
window.close()"&gt; name="Close">, but this causes IE6 to complain about
active content and stops the button from working unless the user
specifically overrides the warning message. That is a pretty ugly solution.

Is there a solution that doesn't rely on Javascript?

How do I enable a print button ?

Thanks for any help -

Dave Broughton


 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIEJ1eWVucw==?=
Guest
Posts: n/a
 
      27th Jun 2005
Sorry, but IE is going to "complain" about anything that tries to close a
window. This is a security measure that keeps rogue sites from closing "real"
windows and opening "conterfeit" windows in their place.

As to printing, try <input type="button" value="Print"
onclick="window.print()">

However, in both cases you're duplicating functions that appear in the
browser's toolbar anyway. Are you sure you need this?

Jim Buyens
Microsoft MVP
http://www.interlacken.com
Author of:
*-----------------------------Â*-----------------------
|\----------------------------Â*-----------------------
|| Microsoft Windows SharePoint Services Inside Out
|| Microsoft Office FrontPage 2003 Inside Out
||----------------------------Â*-----------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/----------------------------Â*-----------------------
*-----------------------------Â*-----------------------


"David Broughton" wrote:

> Hi - I am a very occasional Front Page 2002 user.
>
> I am trying to add a page to my JavaScript-free website that will have a
> table of information (no problem there) and two buttons - one that says
> close and will close the window, and one that says print and will print out
> the contents of the window. The page is opened in a new window using the
> "_blank" target frame hyperlink option.
>
> A search of this newsgroup and other sources found many examples that use
> JavaScript to close a window - i.e.:
> <input type="button" value="Close Order Form" onclick="window.opener = self;
> window.close()"> name="Close">, but this causes IE6 to complain about
> active content and stops the button from working unless the user
> specifically overrides the warning message. That is a pretty ugly solution.
>
> Is there a solution that doesn't rely on Javascript?
>
> How do I enable a print button ?
>
> Thanks for any help -
>
> Dave Broughton
>
>
>

 
Reply With Quote
 
Jon Spivey
Guest
Posts: n/a
 
      27th Jun 2005
Hi David,

No to both - closing and printing a window can only be done with javascript.
This code
<input type="button" value="Close Order Form" onclick="window.opener = self;
> window.close()"&gt; name="Close">

should be
<input type="button" value="Close Order Form" onclick="window.opener = self;
window.close();">
However this code is only needed if you want to close a window that you
didn't open yourself - it's one of those cute tricks that isn't really
useful in the real world. To close a window all you need is
<input type="button" value="Close Order Form" onclick="window.close();">

--
Cheers,
Jon
Microsoft MVP

"David Broughton" <david.broughton@_nospam_sympatico.ca> wrote in message
news:bbVve.3237$(E-Mail Removed)...
> Hi - I am a very occasional Front Page 2002 user.
>
> I am trying to add a page to my JavaScript-free website that will have a
> table of information (no problem there) and two buttons - one that says
> close and will close the window, and one that says print and will print
> out the contents of the window. The page is opened in a new window using
> the "_blank" target frame hyperlink option.
>
> A search of this newsgroup and other sources found many examples that use
> JavaScript to close a window - i.e.:
> <input type="button" value="Close Order Form" onclick="window.opener =
> self; window.close()"&gt; name="Close">, but this causes IE6 to complain
> about active content and stops the button from working unless the user
> specifically overrides the warning message. That is a pretty ugly
> solution.
>
> Is there a solution that doesn't rely on Javascript?
>
> How do I enable a print button ?
>
> Thanks for any help -
>
> Dave Broughton
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      27th Jun 2005
Hi David,

Closing a window is a process. Process means programming. HTML is not
process; it is simply content. As soon as you talk about DOING something,
you're talking about process. The same, of course, goes for Printing.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"David Broughton" <david.broughton@_nospam_sympatico.ca> wrote in message
news:bbVve.3237$(E-Mail Removed)...
> Hi - I am a very occasional Front Page 2002 user.
>
> I am trying to add a page to my JavaScript-free website that will have a
> table of information (no problem there) and two buttons - one that says
> close and will close the window, and one that says print and will print
> out the contents of the window. The page is opened in a new window using
> the "_blank" target frame hyperlink option.
>
> A search of this newsgroup and other sources found many examples that use
> JavaScript to close a window - i.e.:
> <input type="button" value="Close Order Form" onclick="window.opener =
> self; window.close()"&gt; name="Close">, but this causes IE6 to complain
> about active content and stops the button from working unless the user
> specifically overrides the warning message. That is a pretty ugly
> solution.
>
> Is there a solution that doesn't rely on Javascript?
>
> How do I enable a print button ?
>
> Thanks for any help -
>
> Dave Broughton
>



 
Reply With Quote
 
Andrew Murray
Guest
Posts: n/a
 
      28th Jun 2005
It only complains about active content unless it is on a web server. if you
are testing the scripts on your local machine, you'll always get that
message.

"David Broughton" <david.broughton@_nospam_sympatico.ca> wrote in message
news:bbVve.3237$(E-Mail Removed)...
> Hi - I am a very occasional Front Page 2002 user.
>
> I am trying to add a page to my JavaScript-free website that will have a
> table of information (no problem there) and two buttons - one that says
> close and will close the window, and one that says print and will print
> out the contents of the window. The page is opened in a new window using
> the "_blank" target frame hyperlink option.
>
> A search of this newsgroup and other sources found many examples that use
> JavaScript to close a window - i.e.:
> <input type="button" value="Close Order Form" onclick="window.opener =
> self; window.close()"&gt; name="Close">, but this causes IE6 to complain
> about active content and stops the button from working unless the user
> specifically overrides the warning message. That is a pretty ugly
> solution.
>
> Is there a solution that doesn't rely on Javascript?
>
> How do I enable a print button ?
>
> Thanks for any help -
>
> Dave Broughton
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Javascript popup window not showing the contents but about:blank jarathna Windows XP Internet Explorer 1 12th Dec 2007 10:23 PM
Open new window in codebehind and add the window handle to javascript array RJN Microsoft ASP .NET 1 10th Oct 2004 08:53 PM
window.moveTo() & window.resizeTo() are not firing in Javascript for minimizing Kevin Windows XP Internet Explorer 0 19th Apr 2004 07:22 PM
need JavaScript to prevent people from closing a browser window Daniel Walzenbach Microsoft ASP .NET 8 18th Oct 2003 12:38 AM
File+New+Window;Ctrl+N;JavaScript will not open Window DKing Windows XP Internet Explorer 0 1st Aug 2003 03:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:50 AM.