Nw.js: open links real browser

Created on 30 Sep 2013  Ā·  12Comments  Ā·  Source: nwjs/nw.js

is there any way to open all target="_blank" links in real browser?

Most helpful comment

AĀ little help from jQuery makesĀ it possible:

$('a[target=_blank]').on('click', function(){
   require('nw.gui').Shell.openExternal( this.href );
   return false;
});

Update. InĀ theĀ aboveĀ code IĀ assume that this.href contains theĀ completeĀ URL evenĀ if href="…" attribute doesĀ not. ThisĀ assumption is likely toĀ beĀ true.

All 12 comments

AĀ little help from jQuery makesĀ it possible:

$('a[target=_blank]').on('click', function(){
   require('nw.gui').Shell.openExternal( this.href );
   return false;
});

Update. InĀ theĀ aboveĀ code IĀ assume that this.href contains theĀ completeĀ URL evenĀ if href="…" attribute doesĀ not. ThisĀ assumption is likely toĀ beĀ true.

i have some iframes shown normal external web page(not node-webkit app).
can i do something to make them all open new window in real browser?

2013/9/30 Mithgol [email protected]

A little help from jQuery http://jquery.com/ makes it possible:

$('a[target=_blank]').on('click', function(){
require('nw.gui').Shell.openExternal( $(this).href );
return false;});

In the above code I assume that href="…" attributes of such links contain
complete URLs.

—
Reply to this email directly or view it on GitHubhttps://github.com/rogerwang/node-webkit/issues/1162#issuecomment-25338627
.

We could imagine some new linkout attribute and make aĀ featureĀ request to @rogerwang for <iframe nwdisable nwfaketop linkout>.

I support this feature request, but do not forget to cover popup windows al well!
In my application I open insecure external content not in iframes but in those popup windows like here:

require('nw.gui').Window.open(url, {
    nodejs: false,
    "new-instance": false
});

An option linkout: true would be grand!

I think you can use node-open to do this.

https://github.com/pwnall/node-open

Indeed, these's atĀ least one useĀ case (#1154) where node-open behaves better than Shell.openExternal.

However, here theĀ mainĀ problem is that theĀ task of attaching either ofĀ those handlers toĀ every _blank link is aĀ largeĀ one andĀ thus it's natural toĀ start wondering if theĀ engine could doĀ that forĀ us.

look forward to the linkout attribute

you can now handle it in the new-win-policy handler.

Also you can use the node-open

@sergiovilar That tool was mentioned here 6Ā monthsĀ ago.

Oh, Sorry. I don't have seen it

nw.Shell.openExternal('http://google.com');

Was this page helpful?
0 / 5 - 0 ratings