Window Print JS

Hello,

I was wondering how to make a button open a new window and automatically print it via Javascript and just give the button a class. Is this possble? I know that a force download is possible so I thought this would be similar but could not find anything on the apex.

Thanks,
-Joe

Hi Joe,

Thanks for writing in! Your request is beyond the scope of our support as it will require custom development.

However the following resource should help you to get started (https://stackoverflow.com/questions/241570/auto-start-print-html-page-using-javascript).

If you’re using button shortcode, you can use the parameter target and set it to blank.

Example:
[button target="blank" type="real" shape="square" size="mini" href="http://my.link" title="Example"]Print[/button]

Also in cornerstone, you have the ability open in a new tab.

If you’re referring to a popup window, you will need to use custom JS as well to implement that functionality.

Thanks!

Ok. But I saw in another post that you helped someone with a custom jquery to do a force download. Are you saying that what I am asking is more complicated and thus is not part of support?

jQuery( document ).ready(function($) { $( ".forcedownload" ).attr( "download", "" ); });

Hi @jgreenberg,

That’s just based on browser default feature and it may not always work. But yes, you can use the same code. Example,

[button target="blank" type="real" shape="square" size="mini" href="http://my.link" title="Example" class="forcedownload"]Print[/button]

Then the jQuery code that you need to add to your builder’s custom javascript section is this

jQuery( document ).ready(function($) {
$( ".forcedownload" ).attr( "download", "new_file_name" );
});

We can’t provide customization and it’s not part of the theme or the builder. We do provide snippets but it’s only limited how much we know about it or familiarity. We can’t always provide any snippet.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.