最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to detect if user has already opened an url and redirect to same if already opened? - Stack Overflow

programmeradmin1浏览0评论

Can anyone please tell me how can I detect if user has already opened the link/url tab and is it possible to redirect a link to a active browser tab if the url is already opened?

Eg: User clicks on the link and js code will open a new tab in browser.Now if user again clicks on the link I want him to redirect to the active session instead of opening a new tab.

I read the below post but unable to implement my logic according to them:

Java: ensure web application open only in one browser tab
Possible to detect if a user has multiple tabs of your site open?

I am using simple window.open(url) to open my url in new tab.

Thanks....

Can anyone please tell me how can I detect if user has already opened the link/url tab and is it possible to redirect a link to a active browser tab if the url is already opened?

Eg: User clicks on the link and js code will open a new tab in browser.Now if user again clicks on the link I want him to redirect to the active session instead of opening a new tab.

I read the below post but unable to implement my logic according to them:

Java: ensure web application open only in one browser tab
Possible to detect if a user has multiple tabs of your site open?

I am using simple window.open(url) to open my url in new tab.

Thanks....

Share Improve this question edited May 23, 2017 at 10:25 CommunityBot 11 silver badge asked Jun 27, 2013 at 14:37 PanwarS87PanwarS87 3195 silver badges15 bronze badges 4
  • I'm pretty sure that would be a privacy violation. Anyway, are those links from the same domain? – MaxArt Commented Jun 27, 2013 at 14:38
  • Yes they are for same domain and we are performing SSO to validate so security violation is not a concern. – PanwarS87 Commented Jun 27, 2013 at 14:47
  • I said privacy, not security :) I thought you needed to check the client's browser history to perform your task. That's not allowed (anymore). – MaxArt Commented Jun 27, 2013 at 15:38
  • oh! yea, sorry about that. But the below solutions worked well for me.I am a newbee in UI, still learning all tips and tricks :) – PanwarS87 Commented Jun 27, 2013 at 16:47
Add a ment  | 

2 Answers 2

Reset to default 4

if you give a name to the opened window it will reopen the same the second time

    window.open(url,"mypopup");

use the target/window name in javascript do that

window.open(yoururl, youruniquewindowname)

example

window.open("https://stackoverflow./", "stack_unique_123")

if a window with stack_unique_123, is already open, the "https://stackoverflow./" will be reload in that window, preventing a new one to be open.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论