473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

how to hide unwant objects to print?

I try to hide the print preview button that inside <div id="button"> when previewing the page. But the the problem happened the button is always hidden after i closing the preview page. Anyone have an idea how to overcome this? Here is the code;

[HTML]<html>
<head>
<script language="javascript">
function printpreview()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 8 - page setup (for printing)
* 1 - open window
* 4 - Save As
* 10 - properties
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
document.getElementById('form').style.display='blo ck';
document.getElementById('button').style.display='n one';
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}
</script>
<title>Print Preview</title>
</head>

<body>
<div id="form">
<table id="schedule" width="200" cellpadding="1" cellspacing="1" border="1">
<tr align="center">
<td width="50%">ID</td>
<td width="50%">Value</td>
</tr>
<tr align="center">
<td width="50%">1</td>
<td width="50%">OK</td>
</tr>
<tr align="center">
<td width="50%">2</td>
<td width="50%">OK</td>
</tr>
</table>
</div><br />
<div id="button">
<input name="Print" id="Print" type="button" value="Print Preview" onclick="printpreview();" />
</div>
</body>
</html>
[/HTML]
Oct 1 '07 #1
7 3401
It's ok i have been got the solution a while ago! Here the code as folowing;

[HTML]<script language="javascript">
function printpreview()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 8 - page setup (for printing)
* 1 - open window
* 4 - Save As
* 10 - properties
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
if(document.getElementById('button').style.display ='none')
{
document.getElementById('form').style.display='blo ck';
}
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
document.getElementById('button').style.display='b lock';
}
</script>[/HTML]
Oct 1 '07 #2
But, how to hide the mainFrame if i use three frames (leftFrame, mainFrame, topFrame) and i put the code inside the mainFrame? Your help are appreciete, thanks

Regard;

Fareast Adam
Oct 1 '07 #3
acoder
16,027 Expert Mod 8TB
Set the frameset's rows or cols attribute to the correct percentage to hide the frame. Show the code for the frameset.
Oct 1 '07 #4
The topFrame and leftFrame are hidden while previewing mainFrame but i still not got an expected result, previewing only 'complaint'. Here the code as below;

[HTML]function printpreview()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 8 - page setup (for printing)
* 1 - open window
* 4 - Save As
* 10 - properties
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
window.parent.frames('mainFrame').document.getElem entById('complaint').document.body.insertAdjacentH TML('beforeEnd', WebBrowser);

window.parent.frames('leftFrame').document.body.st yle.display='none';
window.parent.frames('topFrame').document.body.sty le.display='none';

WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = '';

window.parent.frames('leftFrame').document.body.st yle.display='block';
window.parent.frames('topFrame').document.body.sty le.display='block';
}[/HTML]
Oct 1 '07 #5
acoder
16,027 Expert Mod 8TB
This print preview code will probably only work in IE.

What happens instead of the expected result?
Oct 2 '07 #6
All leftFrame and topFrame contents are hidden but the problem is both size never change! What i want is to hide both frames while the specified contents inside the mainFrame is only preview not all the mainFrame contents.
Oct 2 '07 #7
acoder
16,027 Expert Mod 8TB
Can you show your frameset code?
Oct 2 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Rich | last post by:
i have a web page that uses a javascript function to show/hide some info using css "visibile" "hidden" attributes of "id". the js was a free script that i modified for my use. works great. to...
5
by: Steve | last post by:
Visual Studio 2003 C# Windows: I have a tree view control as my main menu control down the left side of my application. This has 2 Parent Nodes on it (Jobs and Employees). beneath these 2 main...
3
by: Tom Jones | last post by:
I do not understand what is meant when someone states that a given method is "hidden" verses overriden. Would someone please provide a short example of both cases and why you might want to...
161
by: KraftDiner | last post by:
I was under the assumption that everything in python was a refrence... so if I code this: lst = for i in lst: if i==2: i = 4 print lst I though the contents of lst would be modified.....
2
by: larry | last post by:
I'm trying to print screen in my MFC application. I want to capture screen in OnBeginPrinting( ), but my program capture the print dialog box too. How can I hide print dialog box and just print...
5
by: xrado | last post by:
when i say window.hide(), window dont hide imidetly i want to hide it for a few seconds, do something and then show it back how can i do this? i have this example: import pygtk,time...
3
by: deciacco | last post by:
I'm trying to write a label printing SDI app with a small preview on the main form itself. Every time I run the InvalidatePreview event on the preview control to redraw the preview I get the...
10
by: sara | last post by:
Hi - Is it possible to hide the detail section of a report at run time? I have a report that prints all details, with summary lines. The user would like the report ALSO with just summary lines....
47
by: SOLAV | last post by:
This is the only working way to completely hide your JavaScript code from the client just like PHP or ASP code. Here we'll need the help of PHP. Here is the code: index.php...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.