![]() |
|
|
| 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. | |
| |
| |
|
|
| 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 |
|
| 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 :). |
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 Home - Answers FAQ - Terms of Service - Privacy Policy |