fotograf
Posts: 7
Joined: Thu Oct 04, 2007 2:22 pm

Print button Html site Ajax

I have a test site - not finish yet - where I want to place a Print button on a text.

http://sample.image2use.dk/fotoweb/Author5.fwx - look on the "læs aftale" - this is the text - that I want to print.

Best regards
Keld
User avatar
RoadRash
Posts: 8249
Joined: Tue Jul 15, 2008 6:43 pm
Location: Fredrikstad, Norway
Contact: Website

Re: Print button Html site Ajax

Hilde
Highslide Support Team

Overview of my Highslide sample pages: RoadRash.no
fotograf
Posts: 7
Joined: Thu Oct 04, 2007 2:22 pm

Re: Print button Html site Ajax

Yes - I have seen the link before, but where and how can I put it in here:

<td>Aftale mellem Image2use og rettighedshaver</td>
<td><a href="i2u_aftale.html" onclick="return hs.htmlExpand(this, { objectType:'ajax' } )"
>Læs aftale</a>
</td>

Best regards
Keld
User avatar
RoadRash
Posts: 8249
Joined: Tue Jul 15, 2008 6:43 pm
Location: Fredrikstad, Norway
Contact: Website

Re: Print button Html site Ajax

Add this in the same script tag as hs.graphicsDir = 'highslide/graphics/'; between the head tags:

Code: Select all

hs.Expander.prototype.printHtml = function ()
{
    var pw = window.open("about:blank", "_new");
    pw.document.open();
    pw.document.write(this.getHtmlPrintPage());
    pw.document.close();
    return false;
};
hs.Expander.prototype.getHtmlPrintPage = function()
{
    // We break the closing script tag in half to prevent
    // the HTML parser from seeing it as a part of
    // the *main* page.
    var body = hs.getElementByClass(this.innerContent, 'DIV', 'highslide-body') 
        || this.innerContent;

    return "<html>\n" +
        "<head>\n" +
        "<title>Temporary Printing Window</title>\n" +
        "<script>\n" +"function step1() {\n" +
        "  setTimeout('step2()', 10);\n" +
        "}\n" +
        "function step2() {\n" +
        "  window.print();\n" +
        "  window.close();\n" +
        "}\n" +
        "</scr" + "ipt>\n" +
        "</head>\n" +
        "<body onLoad='step1()'>\n" +
        body.innerHTML +
        "</body>\n" +
        "</html>\n";
};
Add this at the bottom of your page ÔÇô right before the closing body tag </body>:

Code: Select all

<div class="highslide-html-content" id="print">
	<div class="highslide-header">
		<ul>
        	<li>
				<a  onclick="return hs.getExpander(this).printHtml()" href="javascript:;">Print</a>
			</li>
			<li class="highslide-move">
				<a href="javascript:;" onclick="return false">Move</a>
			</li>
			<li class="highslide-close">
				<a href="javascript:;" onclick="return hs.close(this)">Close</a>
			</li>
		</ul>
	</div>
	<div class="highslide-body">
	</div>
    <div class="highslide-footer">
        <div>
            <span class="highslide-resize" title="Resize">
                <span></span>
            </span>
        </div>
    </div>
</div>
Add contentId: 'print' to the onclick for the popup you want to print:

Code: Select all

<a href="i2u_aftale.html" onclick="return hs.htmlExpand(this, { objectType:'ajax', contentId: 'print' } )">Læs aftale</a>
Hilde
Highslide Support Team

Overview of my Highslide sample pages: RoadRash.no
fotograf
Posts: 7
Joined: Thu Oct 04, 2007 2:22 pm

Re: Print button Html site Ajax

Perfect!

Thank you :lol:

Have a nice easter!

Keld

Return to “Highslide Editor”