Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening links in a specific tab - from an email

I have a registration system on my website which uses the common activation email trick. This email simply contains instructions and a link to the activation page on my website. So suppose I registered on the site, opened a new tab to check my emails and then clicked on the link, which will open in another new tab, resulting in two tabs open on the site (of which one is btw still telling them to o check their mail).

Is there a way to get the link in the email to open in the first tab on my website? (Or open a new tab if the previous one was closed or moved to another domain).

Thanks for any help/suggestions!

like image 465
Sean Bone Avatar asked Aug 23 '12 11:08

Sean Bone


People also ask

How do you open a specific tab via an external link?

tab=x (where x=tab number) to the URL to display the specific tab. For example: https://demo.dj-extensions.com/dj-tabs/?tab=4 will open 4th tab on the demo site, you can try changing the number to another one to see how it works.

Should email links open in a new tab?

Best Practices. Most links should not open in a new tab or window by default using the target="_blank" attribute. By keeping the default link behavior, users can then decide for themselves whether to open the page in a new tab or window. Links that open in the same tab or window are also more secure for your users.

How do I change what a link opens in a new tab?

Hold down the Ctrl key and click the link. Use the wheel button of your mouse to click the link. Right-click the link and then click Open link in new tab.

How do I get email links to open automatically?

On the right side of the URL's address bar, there is an icon with two intertwined diamonds that will appear: Click on the icon to get a pop-up menu that asks, "Allow mail.google.com to open all links?" Select the "Allow" menu option so that the next time an email opens, it will automatically open in Gmail.


1 Answers

You can name your current window/tab with a JavaScript assignment:

<script type="text/javascript">
    this.name = "mainWindow";
</script>

Then you use that name as value for the target attribute in links, like

<a href="nextPage.html" target="mainWindow">...

If mainWindow does not yet (or no more) exist, it will open in a new tab.

Update

The above stuff does not solve the OP's problem, because for links opened from emails, the target attribute will usually not be transferred from MUA to browser (except maybe for webmailers, but we cannot rely on this). So I was thinking of some kind of landing page which uses JavaScript to achieve the desired effect:

  1. If target window/tab `mainWindow` has already been opened, focus it, perform activation there, and close ourselves.
  2. If target window/tab does not exist, perform activation right where we are.

If this worked, you would only see a second open tab for a moment (case 1), before it closes itself. Yet it is not possible to "close ourselves", as I learned here and here - so in the end there would be a superfluous tab left, which should have been avoided. Seems like it cannot be done, sorry!

like image 98
f_puras Avatar answered Nov 15 '22 19:11

f_puras