Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 860
  • Last Modified:

printer page break and javascript iframe - help

Hello Experts,
I am trying to achive the page break for printer using one of the methods previously metnioned. in the Q
http://www.experts-exchange.com/Web/Web_Languages/HTML/Q_20169459.html
http://www.experts-exchange.com/Web/Web_Languages/Q_21181900.html

But when I print the javascript it does not insert the page break please guide me.

<style>
   .breakhere {page-break-after:always}
</style>

<iframe name="backFrame" id="backFrame" height="0" width="0"></iframe>
                  
                                                <input type=button value="Print" onClick="printMe(myGeneratedHTML)">

                                                      <script>
                                                      myGeneratedHTML='something<span class="breakhere"> &nbsp;</span>somethingagain'
                                                            function printMe(myGeneratedHTML) {
                                                            window.frames["backFrame"].document.write(myGeneratedHTML)
                                                            window.frames["backFrame"].document.close()  
                                                            setTimeout('window.frames["backFrame"].focus();window.frames["backFrame"].print();',100)
                                                            }
                                                      </script>


Regards,
---Pinal
0
pinaldave
Asked:
pinaldave
1 Solution
 
alain34Commented:
try to use these 2 changes

your style should be
page-break-before:always;

use div as opposed to span.
div is a block element, and page-break-before apply to block element, however I'm not sure span will work with it!
0
 
Michel PlungjanIT ExpertCommented:
Yes, you forgot to include the style...

try

myGeneratedHTML='something<h1 style="page-break-before:always">&nbsp;</h1>somethingagain'
0
 
pinaldaveAuthor Commented:
thank you very much mplungjan...
That worked like magic.
:)
---Pinal
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now