When a user logs in, the home page is blank. Good. But I also want to add a menu item that says “New Tab/Window” where the user clicks it and it opens up a second instance of the blank home page on a new tab in the browser. I can do this manually by right clicking on a menu item. But I want an explicit menu item to do this so that the user know it’s possible.
Likey requires a JavaScript guy to jump in
- Create a page in your Builder called New Tab
- Add this to your custom JS:
$(document).on('knack-scene-render.any', function(event, scene) {
const newTab = $('[data-kn-slug="#new-tab"]') // replace #new-tab with your url
newTab.attr('target', '_blank')
newTab.attr('href', '#login') // replace #login with your home url
})
Great. Thanks again.
So this works as advertised. How would I change the page title (tab label) to reflect what ever page the user goes to?
@JurgenPeter Feel free to send me a private message so I can learn more about your use-case. Happy to take a look.
Do you want the user’s current page to open in a new tab when they click “New Tab”?
If so you can do this:
- Create a page in your Builder called New Tab
- Add this to your Custom JS:
$(document).on('knack-scene-render.any', function(event, scene) {
const newTab = $('[data-kn-slug="#new-tab"]') // replace #new-tab with your url
const currentPage = location.href
newTab.attr('target', '_blank')
newTab.attr('href', currentPage)
})