31

How to Add a Back Button for Full-Screen Mode with SCSS Styling

Powered by WPCodeBox

Learn how to add a responsive “Back to WP” button to your full-screen mode with custom SCSS styling. This snippet provides the JavaScript for button insertion and SCSS for styling, including hover effects, to enhance user navigation and experience.


window.addEventListener("load", () => {
    const __BAKK = document.createElement("a");
    __BAKK.id = "x91-back";
    __BAKK.textContent = "Back to WP";
    const ___LPTH = window.location.origin + window.location.pathname;
    __BAKK.href = ___LPTH.substring(0, ___LPTH.lastIndexOf("/") + 1);
    document.body.appendChild(__BAKK);
});

Other Snippets

WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.