top of page
atlan logo green.png

Start a project

Start a project

Social Share Buttons for Wix Dynamic Pages
Selected work
Social Share Buttons for Wix Dynamic Pages

Practical guides on Wix Studio, Velo, Squarespace, e-commerce and SEO — written from real client projects.

Atlan Design

Atlan Design

December 31, 2023 · 1 min read

Custom social share buttons for Wix dynamic pages

import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {

    let siteUrl = wixLocation.url;

    $w("#facebookShare").link = `https://www.facebook.com/sharer.php?u=${siteUrl}`;
    $w("#twitterShare").link = `https://twitter.com/intent/tweet?url=${siteUrl}`;
    $w("#pinterestShare").link = `http://pinterest.com/pin/create/button/?url=${siteUrl}`;
    $w("#linkedInShare").link = `https://www.linkedin.com/sharing/share-offsite/?url=${siteUrl}`;

    //TRIGGER URL BOX
    $w("#urlTrigger").onClick(() => {

        $w("#urlBox").collapsed ? $w("#urlBox").expand() : $w("#urlBox").collapse();

    });

    //ADD URL TO BUTTON LABEL
    $w("#urlButton").label = siteUrl;

    //COPY TO CLIPBOARD
    $w("#urlButton").onClick(() => {

        wixWindow.copyToClipboard(siteUrl).then(() => {

            $w("#urlButton").label = `Recipe URL copied!`

            setTimeout(() => {

                $w("#urlButton").label = siteUrl;

            }, 1000);

        })

    })

});

Have fun!

Keep reading

Journal

Social Share Buttons for Wix Dynamic Pages

Writer: Atlan Design
Atlan Design
Dec 31, 2023
1 min read

Updated: Sep 19


Custom social share buttons for Wix dynamic pages

import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {

    let siteUrl = wixLocation.url;

    $w("#facebookShare").link = `https://www.facebook.com/sharer.php?u=${siteUrl}`;
    $w("#twitterShare").link = `https://twitter.com/intent/tweet?url=${siteUrl}`;
    $w("#pinterestShare").link = `http://pinterest.com/pin/create/button/?url=${siteUrl}`;
    $w("#linkedInShare").link = `https://www.linkedin.com/sharing/share-offsite/?url=${siteUrl}`;

    //TRIGGER URL BOX
    $w("#urlTrigger").onClick(() => {

        $w("#urlBox").collapsed ? $w("#urlBox").expand() : $w("#urlBox").collapse();

    });

    //ADD URL TO BUTTON LABEL
    $w("#urlButton").label = siteUrl;

    //COPY TO CLIPBOARD
    $w("#urlButton").onClick(() => {

        wixWindow.copyToClipboard(siteUrl).then(() => {

            $w("#urlButton").label = `Recipe URL copied!`

            setTimeout(() => {

                $w("#urlButton").label = siteUrl;

            }, 1000);

        })

    })

});

Have fun!

Comments


bottom of page