I have one-page JS tool. When some event is fired, user got an e-mail. In it there is a link to my tool. But I do not wand to open new tab with duplicated tool to let user do smth. with fired event.
I want to redirect him from e-mail to already opened tab (if it exists, or simply open new) and set new data.
Like this: suppose user has tab with http://example.com/ opened, then he got an e-mail with link to http://example.com/?open=sometab_int_the_tool. In normal way, when user click on that link, he got duplicated tab with http://example.com/. But obviously, the better way is to open existed tab and send to it command to open some tab.
How can I do this?
Related
I'm building a site that let's the user share their creation to WhatsApp by means of a WhatsApp share link. In case of desktop-screens I refer to web.whatsapp.com in a new window. But I know lot's of cases Web.whatapp.com is already open, and this would disconnect the open tab and continue in the new one.
Is there a way to check if a browser tab already has a WhatsApp tab open? And append the message to the existing tab?
<li id="wa4" class="wa">Whatsapp (web)</li>
In my current implementetion of two-factor auth, I'm sending a SMS to the user with a link. When the link is clicked, the login proceedes on the users machine.
However, on the phone the browser will open up a empty page (since I'm currently returning 204 from the webserver for the link clicked in the SMS.
What I would like to happen is that when the user clicks the link in the SMS, the broser is not opened at all. It should just send the GET request, and the user will not have to close the browser window on his phone.
If that is not possible, is it possible to make the window that get's opened to autoclose imediately?
The browser has to open to make the request. There's nothing you can do about this.
However, if you control the content from the web server, you can attempt a window.close() on-load. Realistically, you'll probably get blocked on this and should also have a fallback content that says something like, "logged in, please close this window". (You can probably call window.close() on a button click.)
My use case:
User already has web app open in a browser tab
An email is sent to the user with an anchor tag that takes user to a specific page in the web app
On clicking, the initial tab is repopulated with new page
To do this the anchor tag is formatted like <a target="webapp" href="example.com" >Click Here</a> and I have a tiny bit of javascript, triggered on load, in my web app like this window.name="webapp"
What is working:
If I test to make sure the window name was with window.name="webapp", doing console.log(window.name), it confirms that it was
If I click the link from the email and the web app isn't open yet a new tab opens. If I click that link again the tab that initially opened refreshes.
What isn't work:
If the user initially navigates directly to the web app (not via a link) and then clicks the link from the email, the link opens a new tab instead of repopulating the open tab. In this scenario I still get the correct window name in the console log but not the functionality I'm looking for.
Looking for insight into how to get this to work or if there's a better solution to this use case.
In the website I am building I have a link to another webpage set with a target of _blank to open in a new tab.
If I click the link and then switch back to the 1st page and click the link again it opens a 3rd tab.
Is there any way to get the browser to just switch back to the already open tab for the 2nd webpage?
You can use target="secondPage", this create a named window/tab and every links that a user click that has this target will be opened in this page.
Other than this, I don't think it's possible nor a good thing. You should not tell the user how to manage his tabs/windows.
i have three links in my page, i want to restrict the user to open a link one at a time. So how to check through javascript when user clicks on a link whether it has been opened already a window or not(by opened i mean not just click the link and close it, the window should be opened at the time when user clicks on link).
Give the windows a name, then you can access them using the DOM. Every time a user opens a new popup window you could run a loop that will try and access all the popups. If another window is open already you can stop the current popup event from happening.
The popups would all have to be under your domain for this to work.