Open every link in a new window


#1

Iam using the below code to open a link in a new electron window:

$('body').on('click', '.openlink', function () { var url = 'https://www.google.com' + this.id; window.open(url,"_blank","height=650,width=1000,frame=true,show=true"); });

However, when I click the button again, the other page opens in the same window that google.com opened. How can I open new button clicks on new windows every time ?


#2

I’m so new to Electron and web stuff in general this could be wrong. But I hope this helps. I too, wanted to open new windows in Electron and found that just by adding "target=‘blank’ " in the link works.
Johnf


#3

I also found window.open(). I’m not to sure how it works yet but it does open a new window.
Johnf


#4

Hello. Thanks for the reply, where exactly do you put target=blank ?


#5

where you need the link. In my case I’m using a nav-bar so I line that works is:
a class=“navbar-item is-hidden-desktop” href=“page1.html” target="_blank"

Of course it does not have to be from a nav-bar (bulma css component) it could be from a menu item. Somewhere you have to tell the program where to go on the a click event or some other function.


#6

It still doesnt work for me man


#7

OK let’s try this:

<html>
<body>

<p>Open "myWindow" </p>

<button onclick="openWin()">Open "myWindow"</button>
<script>
var myWindow;

function openWin() {
    myWindow=window.open("", "myWindow", "width=200, height=100");
    myWindow.document.write("<p>This is 'myWindow'</p>");
}
</script>

</body>
</html>