❌

Reading view

How can I hide sections of a page to users other than windows visitores on wordpress?

I have a page with an artical, at the bottom of that page I would like to post an image with a link that useres visiting the page on mobile devices or desktops other than windows don't see. I tried a JavaScript snippet but it returns an error in functions.php when trying to save it.

the snippet:

document.addEventListener("DOMContentLoaded", function() {

const isWindows = navigator.platform.indexOf("Win") !== -1 || navigator.userAgent.indexOf("Windows") !== -1;

if (isWindows) {

const targetElement = document.getElementById("windows-only-content");

if (targetElement) {

targetElement.style.display = "block";

}

}

});

how can i get a better solution?

submitted by /u/Sure_Strike9872
[link] [comments]
  •  
❌