Что вы хотите сделать, это перехватить ссылки во внутреннем фрейме.
Здесь у нас есть iframe, где все ссылки будут открываться в браузере по умолчанию, а не в контексте узла WebKit. Надеюсь, это поможет.
Попробуйте это:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
window.gui = require('nw.gui');
handleLinks = function(event)
{
var href;
function checkLinks(element)
{
if (element.nodeName.toLowerCase() === 'a')
{
href = element.getAttribute('href');
if (href)
{
gui.Shell.openExternal(href);
// important, prevent the default event from happening!
event.preventDefault();
}
}
else if (element.parentElement)
{
checkLinks(element.parentElement);
}
}
checkLinks(event.target);
};
function isLoaded()
{
// let's see if the iframe has finished loading
var iframe = document.getElementById('myframe');
if (iframe && iframe.contentWindow && iframe.contentWindow.document &&
iframe.contentWindow.document.body &&
iframe.contentWindow.document.body.innerHTML)
{
//now deal with links
iframe.contentWindow.document.body.addEventListener('click', handleLinks, false);
}
else
{
// not yet, let's wait a bit and try again
setTimeout(isLoaded, 300);
}
};
</script>
</head>
<body>
<iframe id="myframe" src="http://www.google.com" onLoad="isLoaded();" style="width: 100%;" seamless="true" nwdisable nwfaketop></iframe>
<div>
Links in the normal browser should still work in the Node Webkit environment.
</div>
<footer>
<a href="http://www.yoursitehere.com">Whaddayaknow</a>
</footer>
</body>
</html>
Что URL вы пытаетесь открыть? – zaerymoghaddam
Я пытаюсь открыть ссылку на другой сервер, работающий в другом месте. Этого было бы достаточно, если бы я мог открыть google.com в браузере по умолчанию. – magizh