• I would like to be able to click a link on a page and have it open in a widget on the sidebar. Is that possible?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey @delboy007,
    With the help of jquery and vanilla js you can do this task.

    Below put into the sidebar

    <a href="#" class="image-link" data-image="image.jpg">Open Image</a>

    <div class="popup" id="popup">
    <span class="close" id="close">&times;</span>
    <img src="" alt="Popup Image" id="popupImage">
    </div>

    Below put Into the css or custom css

    .popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    }

    .popup img {
    max-width: 90%;
    max-height: 90%;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    }

    .popup .close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    }

    Below put into the custom js

    document.addEventListener("DOMContentLoaded", () => {
    const imageLink = document.querySelector(".image-link");
    const popup = document.getElementById("popup");
    const popupImage = document.getElementById("popupImage");
    const closeBtn = document.getElementById("close");

    imageLink.addEventListener("click", (e) => {
    e.preventDefault();
    const imageUrl = imageLink.getAttribute("data-image");
    popupImage.src = imageUrl;
    popup.style.display = "flex";
    });

    closeBtn.addEventListener("click", () => {
    popup.style.display = "none";
    popupImage.src = ""; // Clear the image
    });

    popup.addEventListener("click", (e) => {
    if (e.target === popup) {
    popup.style.display = "none";
    popupImage.src = ""; // Clear the image
    }
    });
    });

    I hope this maybe be helpful.
    Note : This is static example you can try with dynamic by php code.
    Thanks.

    Thread Starter delboy007

    (@delboy007)

    excellent thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.