mambo5
asked on
a print button...
hi experts,
i need a code, on a print function. this is where i've a link, and when i click the link, it will the print that page. however, i need this link to function in a particular frame. for instance, i've 3 frames in my interface. i put a print hyperlink in one of the frame, and when the user click 'print', it will only print all the things in that frame, not the whole interface.
can this be done?
pls show me the code...thank you very much.
mambo5
i need a code, on a print function. this is where i've a link, and when i click the link, it will the print that page. however, i need this link to function in a particular frame. for instance, i've 3 frames in my interface. i put a print hyperlink in one of the frame, and when the user click 'print', it will only print all the things in that frame, not the whole interface.
can this be done?
pls show me the code...thank you very much.
mambo5
<A HREF="Javascript:document. print();"> Print Frame</A>
put this in each frame you want to print
put this in each frame you want to print
ASKER
hi guys,
i'll try it out and be back later...
thanks for the code..
mambo5
i'll try it out and be back later...
thanks for the code..
mambo5
If I did not forget, window.print() does not work for Netscape. I might be wrong. I do not have Netscape to test on it now.
<script language="JavaScript">
<!--
function print_doc()
{
if ( document.all )
document.print();
else if ( document.layers )
{
alert("Use the Print option from the menu");
}
}
//-->
</script>
<A onClick="print_doc();" style="cursor:hand">Print Frame</A>
hongjun
<script language="JavaScript">
<!--
function print_doc()
{
if ( document.all )
document.print();
else if ( document.layers )
{
alert("Use the Print option from the menu");
}
}
//-->
</script>
<A onClick="print_doc();" style="cursor:hand">Print Frame</A>
hongjun
window.print doesn't work in IE4 either. So this must be tested also in the function from hongjun.
Don't know for Netscape, but I thought it worked in the latest Netscape version but not in others.
A good alternative (Instead of showing an error message, like the function written by hongjun) is not to show the print-button/link if it doesn't work on your browser. So:
-Check the browser and version and show the print if it is IE5 or the latest Netscape (test it on Netscape first then).
Don't know for Netscape, but I thought it worked in the latest Netscape version but not in others.
A good alternative (Instead of showing an error message, like the function written by hongjun) is not to show the print-button/link if it doesn't work on your browser. So:
-Check the browser and version and show the print if it is IE5 or the latest Netscape (test it on Netscape first then).
DirkVe :) I am not aware about it not working in IE 4. Thanks a lot.
hongjun
hongjun
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
makerp,
Alright man!!!
He is checking for IE version :)
Just an enhancement and no offence to makerp.
<SCRIPT LANGUAGE="JavaScript">
<!--
function printWindow() {
bV = parseInt(navigator.appVers ion);
if (bV >= 4)
window.print();
else
alert("Please use the print option from the menu");
}
//-->
</script>
<a href="javascript:printWind ow()">Prin t This Page</a>
Credit to makerp.
hongjun
Alright man!!!
He is checking for IE version :)
Just an enhancement and no offence to makerp.
<SCRIPT LANGUAGE="JavaScript">
<!--
function printWindow() {
bV = parseInt(navigator.appVers
if (bV >= 4)
window.print();
else
alert("Please use the print option from the menu");
}
//-->
</script>
<a href="javascript:printWind
Credit to makerp.
hongjun
Small correction:
if (bV > 4) window.print();
instead of
if (bV >= 4) window.print();
if (bV > 4) window.print();
instead of
if (bV >= 4) window.print();
cheers
I like this type of friendly exchanges :)
hongjun
hongjun
ASKER
hi experts,
i was glad to see you guys, exchanging friendly ideas..ehehe...
thanks for all your codes. now i've the trouble dividing the points...ehehe..
all of you are really good and great..
anyway, i'll try those codes in different version of browser...
b back later...
thanks..
mambo5
i was glad to see you guys, exchanging friendly ideas..ehehe...
thanks for all your codes. now i've the trouble dividing the points...ehehe..
all of you are really good and great..
anyway, i'll try those codes in different version of browser...
b back later...
thanks..
mambo5
ASKER
hi guys, i've tried all your codes, on IE 5.5 and netscape 4.7!
you know, it's really disappointing to view my program, all out of order in netscape.
however, the print function code created makerp and modified by hongjun, works well in IE and netscape.
dirkve, thanks for your comments on how to create a button and a link in your first post. but dirkve, i've tried your last posted method,
use this
if (bV > 4) window.print();
instead of
if (bV >= 4) window.print();
****dirkve, i'm using IE 5.5, but it came out the alert message instead if i use if (bV >= 4) window.print(); !
anyway, thanks for all your codes...thanks..
you know, it's really disappointing to view my program, all out of order in netscape.
however, the print function code created makerp and modified by hongjun, works well in IE and netscape.
dirkve, thanks for your comments on how to create a button and a link in your first post. but dirkve, i've tried your last posted method,
use this
if (bV > 4) window.print();
instead of
if (bV >= 4) window.print();
****dirkve, i'm using IE 5.5, but it came out the alert message instead if i use if (bV >= 4) window.print(); !
anyway, thanks for all your codes...thanks..
So, your problem solved?
hongjun
hongjun
ASKER
yup..yup...thanks..thanks. .
ahh who gets the points
In case you want a BUTTON:
<BUTTON name="print" onCLick="window.print()">P
In case you want a LINK:
<A href="" OnClick="window.print();re