Hello There ,
In my website I have made the modifications such that when clicked on all the products on the website it opens in the new tab , what should i do so that this occurs in the desktop version of website and not in the mobile version .
PS : I added this code to stop the menu from opening in new tab when clicked in mobile , what modifications should be made to stop opening products in new tab .
<script>
window.addEventListener("load", function () {
function handleAnchorTags(selector) {
const menuLinks = document.querySelectorAll(selector);
// Loop through the anchor tags
menuLinks.forEach(function (link) {
// Check if the anchor tag has the target="_blank" attribute
if (link.getAttribute("target") === "_blank") {
// Remove the target="_blank" attribute
link.removeAttribute("target");
// Add a click event listener to open the link in the same tab
link.addEventListener("click", function () {
// Get the link's href attribute
const href = link.getAttribute("href");
// Redirect to the link's href in the same tab
window.location.href = href;
});
}
});
}
// Call the function with different selectors
handleAnchorTags(".offcanvas__menu_ul .offcanvas__sub_menu_item");
handleAnchorTags(".offcanvas__menu_ul .offcanvas__menu_item");
});
</script>
Site url :: https://1ajhtj8ajh4a5fcv-71493648693.shopifypreview.com
Thank You!!
