Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

IE 4 Printing Issues

Posted on 2003-10-29
10
Medium Priority
?
398 Views
Last Modified: 2008-02-26
I actually posted this in Topic:  Javascript but after searching this new site I feel it may be better served in this area.  I am having some issues printing in ie4.  Upon entering press the user receives an error message and nothing prints.  Here is what I have so far and here is what I think from what I have read I need to incorporate into my print function.  Can anyone help get the 2 scripts to work together?  Also I know IE4 dowsn't allow the printing to another window so as long as I can still have my required style sheet scripts included then the target window can go bye bye.

<--my Script

<script language="JavaScript" type="text/javascript">
function printIt(target) {
winId=window.open('','printwin','width=700,height=600, scrollbars=yes');
function a_s(v5) {
     nst[sc++] = v5;
}
winId.document.write('<style>');
winId.document.write(nst.join('\n'));
winId.document.write('<\/style>\n');
winId.document.write(target.replace('vAlign=center align=middle',''));
winId.document.close();
winId.focus();
if (window.print) winId.print();
winId.close();
}
</script>

<--the IE4 script I believe I need
<object id=WBControl width=0 height=0
classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2></object>
<SCRIPT LANGUAGE=VBScript><!-- //
Sub VBPrint() On Error Resume Next
WBControl.ExecWB 6,1
End Sub
// --></SCRIPT>
<SCRIPT LANGUAGE=JavaScript><!-- //
if (navigator.appName.indexOf('Microsoft') !=-1)
  document.write
else if (self.print)
  document.write

<--my Button handler
<input type="button" value="Print" onClick="printIt(document.getElementById('pagecontentDiv').innerHTML);return false">

100 points for a fix for ie4 and 100 points for a fix that incorporates my needed script into the final command
0
Comment
Question by:RayOfChattanooga
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 15

Accepted Solution

by:
VincentPuglia earned 1200 total points
ID: 9649892

<script language="JavaScript" type="text/javascript">
function printIt(target)
{
   winId = window.open('', 'printwin', 'width=700,height=600,scrollbars=yes');

   function a_s(v5)
   {
     nst[sc++] = v5;
   }

   winId.document.write('<style>');
   winId.document.write(nst.join('\n'));
   winId.document.write('<\/style>\n');
   winId.document.write(target.replace('vAlign=center align=middle',''));
   winId.document.close();
   winId.focus();
   if (window.print)
      winId.print();
  else if (document.all)
  {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
     winId.document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(6, 1);//Use a 1 vs. a 6 for a prompting dialog box
     WebBrowser1.outerHTML = "";
  }
  winId.close();
}

Vinny
0
 

Author Comment

by:RayOfChattanooga
ID: 9650944
Vinny,

Thanks for all your help but I am still getting the following error in IE4:  Object doesn't support this property or method.  Do I need to make any modifications to the button itself?  I believe ie4 doesn't support .innerHtml but I am not for certain.

Ray
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9650972
is this the line where you get the error?
  winId.document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(6, 1);

>>I believe ie4 doesn't support .innerHtml but
it does --> that's where it started.


Vinny
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:RayOfChattanooga
ID: 9651065
The error message just points to the line of code holding the button itself:

<input type="button" value="Print" onClick="printIt(document.getElementById('pagecontentDiv').innerHTML);return false">

Thats why I assumed it was the innerHTML that was causing the problem.  In reality I would think it would be the (target) because I am almost certain IE4 doesn't support sending the data to a new window before printing.  I will try and revise the code so upon clicking "print" the print box is initiatted and not the new window then the print box.
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9651250
IE4 does not recognize getElementById...
you will have to send the div's id to the function and let the function figure out what the innerhtml is

<input type="button" value="Print" onClick="printIt('pagecontentDiv');return false">

function printIt(divID)
{
  var target;
  if (document.getElementById)
     target =      document.getElementById(divID).innerHTML
 else if (document.all)
     target =      document.all[divID].innerHTML;

......etc....
}

0
 

Author Comment

by:RayOfChattanooga
ID: 9651505
I am one step closer then I was before and only one step away from finding the print dialog box.  The new window does open now in ie4 but the print dialog still doesn't open.  Would this work?
else if (document.all)
      winId.print();

Or would it be easier to just eliminate the new generated window?  I would rather it not exist but from a tutorial I read if I am not using the post command then I can nnot include my style sheet engine unless the information is passed into a new window.  
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9651528

WebBrowser1.ExecWB(6, 1);//Use a 1 vs. a 6 for a prompting dialog box

WebBrowser1.ExecWB(1,1)
0
 

Author Comment

by:RayOfChattanooga
ID: 9651631
The reason why I didn'r change the 6 to a 1 is because I received multiple errors throughout the page.  None of the pulldown menus would function properly and the print function would lock it up.  When I changed it back to 6 then everything worked except actually printing the page.
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9651660
check at msdn.microsoft.com  search for WebBrowser1
0
 

Author Comment

by:RayOfChattanooga
ID: 9652902
Vinny,

Thanks for the link.  I found out why my print function wouldn't work.  I had one other interactive element in the form that wasn't backwards compatible.  I have since fixed that script to include both getElementById and document.all.  It test fine so far with the new fix but I won't be able to test it in ie4 until tomorrow.  Based on what I read in Microsoft's site it should work without a hitch.  Thanks for all the help and good luck in getting to number one.  As active as you are I am surprised you ain't there already.  
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question