Current location: Hot Scripts Forums » General Web Coding » JavaScript » Print Preview Javascript Frames!!

Print Preview Javascript Frames!!

Reply
  #1  
Old 08-22-05, 08:42 PM
jajalc jajalc is offline
New Member
 
Join Date: Aug 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Print Preview Javascript Frames!!

Hi all,

I m stuck with this frame issue from last 2 days...

All i want is to do a print preview in my page for the top frame only..

We have 3 frames : Body, Messages,Recent

Our site is an intranet site and will only use MSIE

here is my code for print preview.

<script language=javascript>
function printpr()
{
alert(document.getElementById('Body').name);
var PROMPT = 1; var OLECMDID=7; // 2 DONTPROMPTUSER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
//over here instead of previewing all the 3 frames i just want to preview only the body frame. //so is it possible to get the Body.InsertAjacentHTML in the frame or do so trick to just preview BODY frame only?
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = '';
}

Plz. Help

cheers
C

</SCRIPT>
Reply With Quote
  #2  
Old 08-25-05, 05:12 PM
TwoD TwoD is offline
Community Liaison
 
Join Date: Sep 2003
Location: 404
Posts: 1,811
Thanks: 0
Thanked 0 Times in 0 Posts
There's nothing you can change in that script.
All it does is to find the frame named "Body", create an <object> tag, and puts it in the frame. The contents of the <object> tag takes care of ecerything after that. I have no clue to what it does or how it does it.

Body.insertAdjacentHTML only takes the string in WebBrowser and puts it in the Body frame and tells the browser to parse it as HTML. No changes there could change what the <object> does once it's on the page...
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #3  
Old 10-25-05, 04:28 AM
BetterChoice BetterChoice is offline
New Member
 
Join Date: Oct 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
You actually have to pass what you want printed to the body of a hidden page, declare the object on that page and then tel it to print.

I guess you were searching for something like this:
document.frames("Body").document.body.insertAdjace ntHTML('beforeEnd', WebBrowser);

If only... this would work & i assume it would have in previous versions of IE however it exposes a security threat. Don't worry mate you are not the only one out there searching for these answers... how do you think I found this thread.

Glad to help if i did

Daniel Goodhew

Try this & you will see what I mean about the error

<HTML><HEAD>
<script language=javascript>
function Init()
{
EditFrame.document.designMode = "On";
}
function printpr()
{
var WebBrowser = '<OBJECT ID="WebBrowser1" style="WIDTH: 0%; HEIGHT: 0%" CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.frames("EditFrame").document.body.insertA djacentHTML('beforeEnd', WebBrowser);
document.frames("EditFrame").WebBrowser1.ExecWB(7, 1);
}
</script>
</HEAD>
<BODY name="hello" onload="Init()">
<input type=button value="PRINT" name="Print" onClick=printpr()>
<iframe id="EditFrame" style="WIDTH: 100%; HEIGHT: 92%"></iframe>
</BODY></HTML>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classified Ads skipper23 Perl 3 11-22-05 03:22 AM
Mysql Search Output Question doveroh PHP 0 02-15-05 08:39 PM
formmail problem gscraper Perl 12 08-27-04 04:06 AM
Upload Script Problem!!! seanknighton Perl 0 03-21-04 10:54 PM
Classified Ads skipper23 Perl 2 12-30-03 04:43 AM


All times are GMT -5. The time now is 10:58 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 (Unregistered)