Before the new portal experience I was able to use code listed below to make a menu item just a hyperlink to an outside url. That stopped working and I had to put that into a page witht eh hyperlink so I now have to click on it twice. now that things have settled down is there a way to just make a menu item on the navigation bar a hyper link that can go direclty to an ootuside URL
Code I was using:
(() => {
// IMPORTANT Edit this to the URL you want the button to redirect to
const TARGET_URL = "https://example.com";
// CSS selector
const SIDEBAR_SELECTOR = "body"; // leave as body if unsure
// IMPORTANT Text label of the button you want to change (case-sensitive exact match after trimming)
const BUTTON_LABEL = "hyperlink";
// Handler: find matching button(s) and attach a click handler that redirects
function attachRedirectHandlers(root = document) {
const buttons = Array.from(root.querySelectorAll("button"));
buttons.forEach((btn) => {
// skip buttons already processed
if (btn.dataset.redirectAttached === "1") return;
const label = (btn.textContent || "").trim();
if (label === BUTTON_LABEL) {
// capture the click early, stop other handlers, and redirect
btn.addEventListener(
"click",
(e) => {
e.preventDefault();
e.stopImmediatePropagation();
// Optional: small delay so any UI effects complete, remove if you want immediate redirect
window.location.href = TARGET_URL;
},
{ capture: true }
);
// mark processed so we don't attach twice
btn.dataset.redirectAttached = "1";
// optionally change cursor to indicate a link
btn.style.cursor = "pointer";
}
});
}
// Run once in case the element already exists
attachRedirectHandlers(document);
The reason the previous code stopped working is that this type of script usually targets specific page elements, classes, or selectors in the portal interface. Since the new portal experience changed parts of the page structure and styling, the old selectors likely no longer match the navigation item correctly.
Here is an updated script you can add to the Body custom code section of your workspace or portal:
<script>
(function () {
const TARGET_LABEL = "this is a hyperlink";
const REDIRECT_URL = "https://example.com";
document.addEventListener(
"click",
function (event) {
const button = event.target.closest("button");
if (!button) return;
const label = button.querySelector("p");
if (!label) return;
if (label.textContent.trim() === TARGET_LABEL) {
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
window.location.href = REDIRECT_URL;
}
},
true
);
})();
</script>
Please replace TARGET_LABEL with the exact name of the navigation/menu item you want to turn into a link.
Then replace https://example.com with the external URL you want users to be redirected to.
Danny, this worked like a charm - One other question, can you make the left hand menu bar sticky so it doesnt disappear - some of my users do not want it to go away