Google Answers Logo
View Question
 
Q: IE - Firefox Compatible Code ( Answered,   2 Comments )
Question  
Subject: IE - Firefox Compatible Code
Category: Computers > Programming
Asked by: cindy884-ga
List Price: $15.00
Posted: 27 Dec 2004 11:31 PST
Expires: 26 Jan 2005 11:31 PST
Question ID: 447822
Links throughout one page.  Each link opens up different external
pages and prints them.

Link 1, clicked opens up Page A and prints it.

Link 2, clicked opens up Page B and prints it.

Link 3, clicked opens up Page C and prints it.

Ideally, instead of links we would like to use buttons.  But, other
than that, any IE - Firefox compatible code will be acceptable.

Request for Question Clarification by hammer-ga on 28 Dec 2004 08:43 PST
Cindy884,

Do you ever want to open page A, B or C without printing them?

Do you want to open Pages A, B and C in the same window where you
click the button, or do you want them to open in a popup?

- Hammer

Clarification of Question by cindy884-ga on 28 Dec 2004 09:02 PST
Hello Hammer,

Thanks for your reply.  You wrote:

"Do you ever want to open page A, B or C without printing them?"
~~Want them to open and the print dialog box opens also, allowing the
person to print just by clicking the print now in the print dialog
box.

"Do you want to open Pages A, B and C in the same window where you
click the button, or do you want them to open in a popup?"
~~Popup

Many thanks...

Cindy

Clarification of Question by cindy884-ga on 28 Dec 2004 09:13 PST
Hello Again,

You wrote:

"Do you EVER want to open page A, B or C without printing them?"
~~No

Sorry, we missed the "ever".

Thanks,

Cindy
Answer  
Subject: Re: IE - Firefox Compatible Code
Answered By: hammer-ga on 28 Dec 2004 11:10 PST
 
Cindy884,

Below is the source for a simple web page. The page has a link and a
button. Both will open a page called "page_a.html" in a popup if
clicked. Both use a Javascript routine. The only difference between
the two Javascript functions is that one of them returns false.

<HTML>
<HEAD>
<TITLE>Start Page</TITLE>
<SCRIPT language="Javascript">
function show_page_link(page_name)
{
	jWindow = window.open(page_name, 'iwin', 'width=800, height=500,
resizable=yes, scrollbars=yes');
	jWindow.focus();
}
function show_page_button(page_name)
{
	jWindow = window.open(page_name, 'iwin', 'width=800, height=500,
resizable=yes, scrollbars=yes');
	jWindow.focus();
	return(false);
}
</SCRIPT>
</HEAD>
<BODY>

<P><A HREF="javascript:show_page_link('page_a.html')">Go to Page A</A></P>

<FORM onSubmit="show_page_button('page_a.html');">
<INPUT TYPE="SUBMIT" VALUE="Page A">
</FORM>

</BODY>
</HTML>


Page A (and B , C, etc.) work by placing the print command on the
onLoad event for the page. Regardless of how you open the page, it
will always try to print.

<HTML>
<HEAD>
</HEAD>
<BODY onLoad='javascript:window.print();'>
<P>This is Page A</P>
</BODY>
</HTML>

Depending on your particular situation, you may need to tweak this a
bit. If you want to pursue the button method, there is an FAQ section
with instructions for submitting forms using multiple buttons or based
on the value in a dropdown.

IRT.org FAQ - Javascript - Submitting Forms
http://developer.irt.org/script/form.htm#7.2

The IRT.org Javascrit FAQ is excellent. I recommend you take a look
there if you have Javascript questions.
IRT.org Javascript FAQ
http://developer.irt.org/script/script.htm

Good luck with your web project!

- Hammer
Comments  
Subject: Re: IE - Firefox Compatible Code
From: adarshbhat-ga on 03 Jan 2005 01:41 PST
 
The solution suggested sounds pretty good. Also very well written.
Great job hammer!!
Subject: Re: IE - Firefox Compatible Code
From: nazrhyn-ga on 05 Mar 2005 23:23 PST
 
Depending on how important cross-compatibility is, you could add this
enhancement to the print popup page (I believe this event is IE-only):

<HTML>
<HEAD>
</HEAD>
<BODY onLoad='javascript:window.print();'
onAfterPrint='javascript:window.close();'>
<P>This is Page A</P>
</BODY>
</HTML>

This would automatically close the window after the user has completed
the print operation.

Also, you can simplify that page a bit more by just using the <BUTTON>
tag and its onClick event to avoid using the whole <FORM> construct.
One thing I've been known to do when I need to do this sort of thing
is to open the window as small as possible and actually position it at
a negative x and y position on the screen so that it opens offscreen.
This sort of simulates the effect of a print button that prints
something different than what's on the screen without actually opening
anything. Slick :).

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy