ElectronNET / electron.net-api-demos

Explore the Electron.NET APIs
MIT License
313 stars 78 forks source link

How to call a JavaScript function on Menu item click? #10

Closed srameh closed 5 years ago

srameh commented 5 years ago

I need load a different page using ajax from a Menu click. For example I have a FAQ menu item which has its own view. I want to load this on Ajax call. Something similar to openExternal function. How can this be done?

(function () { const shell = require('electron').shell const links = document.querySelectorAll('a[href]')

Array.prototype.forEach.call(links, function (link) {
    const url = link.getAttribute('href')
    if (url.indexOf('http') === 0) {
        link.addEventListener('click', function (e) {
            e.preventDefault()
            shell.openExternal(url)
        })
    }
})

})

GregorBiswanger commented 5 years ago

Comes with the next Electron.NET update.

srameh commented 4 years ago

Is this feature available now? If so where can I find an example of it?