Opening links in a specific tab - from an email

后端 未结 1 838
粉色の甜心
粉色の甜心 2021-02-14 19:34

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.

相关标签:
1条回答
  • 2021-02-14 20:38

    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!

    0 讨论(0)
提交回复
热议问题