window.open / window.print

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dan

    window.open / window.print

    This works in mozilla but I can't figure out why this won't work in
    IE.


    Say I have this html


    <html>
    header goes here
    header goes here
    header goes here
    header goes here
    header goes here


    <div id="thecontent" >
    html goes here
    tables etc
    html goes here
    html goes here
    html goes here
    <tag><tag><ta g>
    </div>

    <img src="url" onclick="printI t()">



    footer html goes here
    footer html goes here
    footer html goes here
    footer html goes here

    </html>


    the printIt function looks like this



    function printIt()
    {
    //grab the div in the html w/o the header & footer text
    content=documen t.getElementByI d('thecontent') ;

    //open a blank window
    w=window.open(' about:blank');

    //write content var html to the window
    w.document.writ e( content.innerHT ML );

    //write some javascript to make the newly opened window print itself.
    w.document.writ eln("<script>") ;
    w.document.writ eln("window.pri nt()");
    w.document.writ eln("</"+"script>" );
    }


    This will cause the print dialog to pop up in mozilla but doesnt
    prompt to print in IE.


    Is this a security issue?
  • Tim Williams

    #2
    Re: window.open / window.print

    <html>
    <script type="text/javascript">
    function printIt()
    {
    //grab the div in the html w/o the header & footer text
    var content=documen t.getElementByI d('thecontent') ;
    //open a blank window
    w=window.open(' about:blank');
    //write content var html to the window
    w.document.open ();
    w.document.writ e("<html>" + content.innerHT ML);
    //write some javascript to make the newly opened window print itself.
    w.document.writ eln("<script>wi ndow.print()</"+"script>" );
    w.document.writ eln("</html>");
    w.document.clos e();
    }
    </script>
    header goes here<br />header goes here<br />
    header goes here<br />header goes here<br />
    header goes here<br />
    <div id="thecontent" >
    html goes here<br />tables etc<br />
    html goes here<br />html goes here<br />html goes here<br />
    </div>
    <img src="url" onclick="printI t()">
    </html>

    Tim


    "dan" <basement_addic t@yahoo.com> wrote in message
    news:744d583c.0 401071653.60281 02b@posting.goo gle.com...[color=blue]
    > This works in mozilla but I can't figure out why this won't work in
    > IE.
    >
    >
    > Say I have this html
    >
    >
    > <html>
    > header goes here
    > header goes here
    > header goes here
    > header goes here
    > header goes here
    >
    >
    > <div id="thecontent" >
    > html goes here
    > tables etc
    > html goes here
    > html goes here
    > html goes here
    > <tag><tag><ta g>
    > </div>
    >
    > <img src="url" onclick="printI t()">
    >
    >
    >
    > footer html goes here
    > footer html goes here
    > footer html goes here
    > footer html goes here
    >
    > </html>
    >
    >
    > the printIt function looks like this
    >
    >
    >
    > function printIt()
    > {
    > //grab the div in the html w/o the header & footer text
    > content=documen t.getElementByI d('thecontent') ;
    >
    > //open a blank window
    > w=window.open(' about:blank');
    >
    > //write content var html to the window
    > w.document.writ e( content.innerHT ML );
    >
    > //write some javascript to make the newly opened window print[/color]
    itself.[color=blue]
    > w.document.writ eln("<script>") ;
    > w.document.writ eln("window.pri nt()");
    > w.document.writ eln("</"+"script>" );
    > }
    >
    >
    > This will cause the print dialog to pop up in mozilla but doesnt
    > prompt to print in IE.
    >
    >
    > Is this a security issue?[/color]


    Comment

    • dan

      #3
      Re: window.open / window.print

      "Tim Williams" <saxifraxREMOVE @THISpacbell.ne t> wrote in message news:<J66Lb.714 5$aD2.5440@news svr27.news.prod igy.com>...

      <snip>


      Thanks!
      [color=blue]
      >
      > Tim[/color]

      Comment

      Working...