top of page
Crumpled Fabric

0

Print Any Page on Wix

Click URL to copy

Sep 5, 2024

8 min read

WIX Ideas Team

Tags: User Interaction Print Page HTML Embed Code

Why Add a Print Button to Your Wix Website?

Sometimes users want to print or save pages for offline use. While browsers allow you to print pages by pressing Ctrl + P, embedding a dedicated print button makes it much more user-friendly and convenient. This tutorial will show you how to implement this on your site so visitors can easily print any page.


Getting Started: Creating a Print Button on Your Wix Website

Step 1: Set Up Your Page and Tutorials

To demonstrate, we’ll be working with a dynamic page in Wix, specifically from my Tutorials section. When users click on a specific tutorial, they’ll be taken to a detailed page, which contains all the relevant information and code snippets. At the top of the page, we’re going to add a custom print icon that, when clicked, allows users to print the entire page.


Step 2: Add an HTML Element

First, you’ll need to add an HTML element to your page. To do this:

  • Click on the plus (+) icon in the Wix Editor.

  • Navigate to Embed Code.

  • Select Embed HTML and add it to your page.

This will create a box where you can insert custom code.


Step 3: Adding the Print Button Code

Now, it’s time to insert the code that will make your print button functional. Here's what you'll need:


  1. Custom Icon for the Print Button: You can customize the print button icon to match your website's style. You can find free icons on websites like FlatIcon. Search for a print icon, download it, and upload it to your Wix website.

  2. Embedding the Icon: Once you’ve uploaded the icon, go to your Media Manager on Wix. Select the icon and copy its URL. This will be used in your code to display the print button.

  3. The Code: Below is a simplified version of the code that you'll insert into the HTML element:


In this code:

  • The background-image URL will be the link to your custom icon.

  • The window.print() function triggers the browser’s print dialog box when the button is clicked.

Once the code is in place, click Update to save your changes. You should see your custom print icon appear on the page.


Step 4: Finalizing the Script

Now, let’s add one last part to make sure everything works correctly:

  1. Go to Settings in your Wix dashboard.

  2. Scroll down to Custom Code and add this script to the header of all pages:

    javascript

    Copy code

    window.addEventListener("message", function(event) { if (event.data === "print") { window.print(); } });

This script ensures that when the print button is clicked, the browser receives the correct command to print the page.


Testing the Print Feature

Once you’ve added the custom code, publish your website and test it on a live page. When you click on the print icon, the print dialog should appear, and you’ll have the option to print the entire page or save it as a PDF.


Important Notes:

  • This feature only works on Premium Wix or Wix Studio websites. If your website is on the free plan, the feature will not work.

  • Be careful not to delete the icon from your media library, as this will break the print button on your site.


Conclusion

Adding a custom print button to your Wix or Wix Studio website is a simple yet powerful feature that enhances user experience. Whether you run a blog, tutorial site, or any other type of content-rich website, this feature provides a professional and user-friendly touch.


If this tutorial was helpful, don’t forget to subscribe to my YouTube channel for more tutorials like this. If you have any questions, feel free to leave them in the comments below or reach out through Wix Ideas. Happy coding!

Code



Leave a comment (0)

Thanks for leaving a comment🎉

RELATED TUTORIALS 🚀

Custom Text Highlighter Color in Wix Studio

Custom Text Highlighter Color in Wix Studio

Customize the color of your highlighted text on your Wix Studio website

bottom of page