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:
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.
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.
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:
Go to Settings in your Wix dashboard.
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🎉
ahmed
May 19, 2024
wix form data
Hi i need your help also in wix form submission
the problem is that some fields are generated when $w.onReady(function () { like day & date and when i choose the student name i get the phone number from database .
and the form save only the field u fill it by ur self like input or dropdown
Reply
Walter Odibi
January 20, 2000
bromar
Sep 29, 2023
Love the tutorial!!!
You are truly great at creating these instructional videos!! Thank you! I am having trouble figuring out . . 'the triggered email' . . it is not being sent to the user submitting the form, the form and the email to the admin works great. . Could you point me to where this might have already been addressed? or any other help? On a second note. .the submit button success/failure message will go back to the default message once it's connected to the data set(I couldn't figure that out either. )
Reply
Walter Odibi
January 20, 2000
kaan
Jun 4, 2023
wishlist and rating system
hello sir I try today 2 hours but not working if you want I pay money can you do this 2 ( wishlist and rating star) system please I send to you invaid
Reply
Walter Odibi
January 20, 2000
Hi there, you can contact me here using the in-app chatbox
Waqas
Apr 16, 2023
Triggered Email Backend
Hi mate please can you send email by backend
Reply
Walter Odibi
January 20, 2000
Hi Waqas, there isn't a backend code for this tutorial. The emails will be sent from the client-side.
Ghan
Dec 29, 2022
Great Tutorial
Hi !
First of all, I want to thank you for your great tutorials, they helped us a lot with the coding.
But I still need your help, if you don't mind. I have based on Save Calculated Field using Wix Data Hooks Codes, to code my form . but the problem is I don't know why the code only reads the computation for "week2" computation and not the "weeks"
here is the code
I also did a separate column in the dataset where the chosen datas for both fields will be placed.
$w.onReady (() => {
$w("#Person").onChange(() => {
$w("#weeks").onChange(() => {
$w("#week2").onChange(() => {
let person = Number($w("#Person").value);
let weeks = Number($w("#weeks").value);
let week2 = Number($w("#week2").value);
$w("#totalLabel").show();
$w("#totalLabel").text = `"${String(weeks * Number(person))}페소"`; //DESIGN YOUR MESSAGE
$w("#totalLabel").text = `"${String(week2 * Number(person))}페소"`; //DESIGN YOUR MESSAGE
});
});
});
});
Reply
Walter Odibi
January 20, 2000
Hi there, thanks for your comment. I see why this is a problem. The onChange() function seems wrong in combination.
To combine onChangeFunctions use this method
$w("#Person, #weeks, #weeks2").onChange(() => {
//code here
});
Walter
Aug 8, 2022
More Details? Watch video
Hi, you can click here to watch the video https://www.youtube.com/watch?v=9bx7-nBeZ5c
Reply
Walter Odibi
January 20, 2000
Walter
Jul 11, 2022
For you
📺 WATCH THE VIDEO https://www.youtube.com/watch?v=AgPJEU8wpp0
Reply
Walter Odibi
January 20, 2000
Walter Odibi
Apr 18, 2022
Awesome Feature
This tutorial shows you how to display views on your Wix repeater.
📺WATCH VIDEO HERE https://www.youtube.com/watch?v=Iz7SdaCSdXg
Reply
Walter Odibi
January 20, 2000
Walter Odibi
Apr 18, 2022
Amazing tutorial
This amazing tutorial will show you how to a comment section to your WIX dynamic page.
📺WATCH VIDEO HERE https://www.youtube.com/watch?v=f8-vJQFNZ_c
Reply
Walter Odibi
January 20, 2000
Walter Odibi
Apr 10, 2022
Great Feature🎉
This amazing tutorial will show you how to add a visitor view counter to your WIX dynamic page.
🚩MORE TUTORIALS https://www.wixgenius.com/wix-tutorials
Reply
Walter Odibi
January 20, 2000