Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Targeting New Window #11

Open
heychrisbarr opened this issue Aug 28, 2022 · 2 comments
Open

Targeting New Window #11

heychrisbarr opened this issue Aug 28, 2022 · 2 comments

Comments

@heychrisbarr
Copy link

Hello,

Is there a way to target a window that you have created with Neutralino with a link from another window? I am hoping to be able to do something where clicking a link in the main window will open a URL in the second window, like this:

onclick="window.open('/url', 'mywin');"

Thanks!

@shalithasuranga
Copy link
Member

Hello.. Thanks for reporting this issue. Could you please check whether you can fulfill your requirement with window.create?

Thanks 🎉

@heychrisbarr
Copy link
Author

heychrisbarr commented Aug 29, 2022

It seems that window.create allows me to create a window and open a URL just fine, but it seems that I can't target that window via a simple link or with window.create after that. Here is what I experience.

<!-- First link opens a new window -->
<a href="#" onclick="Neutralino.window.create('/link1.html', {
          title: 'Window 2',
          exitProcessOnClose: true,
          processArgs: '--window-name=myWindow',
        });">Link 1</a>

<!-- Second link opens a new window, rather than opening in the window named myWindow if it exists -->
<a href="#" onclick="Neutralino.window.create('/link2.html', {
          title: 'Window 2',
          exitProcessOnClose: true,
          processArgs: '--window-name=myWindow',
        });">Link2</a>

<!-- Third link doesn't open -->
<a href="/link3.html" target="myWin">Link 3</a>

With the JS function on a basic webpage I would experience the following:

<!-- First link will create new window named myWin and open the link -->
<a href="#" onclick="window.open('/link1.html', 'myWin');">Link 1</a>

<!-- Second link will do the same, but if myWin already exists, the link will open in the existing window. -->
<a href="#" onclick="window.open('/link2.html', 'myWin');">Link 2</a>

<!-- Third link will open in myWin if it exists or open in a new window called myWin -->
<a href="link3.html" target="myWin">Link 3</a>

Not sure if Neutralino.window.create is intended to allow for this kind of targeting, but it would be convenient in the simple app that I am creating.

Thanks for your guidance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants