Is there a way to change between browser tabs programatically? - javascript

I'm trying to implement the following feature:
You are on website A
You open a link with target=_blank that goes to website B, in a new tab of course
On website B, there is a link that will make refocus on tab for website A.
Please note that I'm developing both websites and both are in Angular. Is there a way to implement this?
The purpose is not to lose the website state, otherwise I could just redirect the user by the website urls, however I'd lose state.
Thanks in advance!

There is no way to perform such action in JS, it would be a nightmare for everyone.
But... link on website B can just be a window.close()... Previous one will be re-focused.
Is it good for you?

You can't change the browser tab that the user is looking at, due to security concerns. Instead, consider redirecting the user and persisting the data in some appropriate way (e.g. a service)

Related

Add possibility to go back in history in new site

I have a website (e.g. www.foo.com) and redirect to another (e.g. www.bar.com) via window.location. Unfortunately the website runs in fullscreen-mode (so no address bar available) and the user interacts with it by touch inputs (no keyboard, no mouse).
Is it somehow possible to go back from www.bar.com to www.foo.com? Does jQuery do the trick?
UPDATE 1:
My problem is, that I dont have any access to www.bar.com.
history.back(); works fine, but I cannot just add another button to the
foreign website, can I?
To be more exact:
I refer from my website to www.google.com. How can I go back from www.google.com to my website?
If you advise me to use history.back() in the other website (e.g. here), please tell me how
I am very thankful
did you try window.history.back(); ?
I think you can do it with document.referrer It returns the URI of the page that linked to this page. w3c

Forcing a user to authenticate using a pop-up

I have a page I want only authenticated users can come to. Also I want to authenticate them using a pop-up when they come to that page, say, twitter bootsrap or foundation. How can I do that if a user can just close it? It's unreliable, isn't it?
There is a risk that the user changes the css properties of your live page, to make it invisible pop-up. A simple tool like Firebug makes this possible. Authentications pages are safer in a page intended for this purpose.

How to identify browser tab?

I would like to identify browser tabs (on my domain) using JavaScript.
I mean that if user open several tabs with my website and submit web form only on one page I want to notify only this page, even if user moves from this page.
It should be max cross browsers solution.
P.S. One of the possible solutions is using "window.name" property, but I do not want to use it because somebody else can use it.
P.S-2: I found one more possible solution: using sessionStorage. It supported by FF3.5+, Chrome4+, Safari4+, Opera10.5+, and IE8+. Oooohhh, I need IE7!!!!
Thank you in advance!
I don't think this can be done. Each browser tab that is opened is basically like a new browser instance. Just like if the user opened another browser. One tab knows nothing about the other tab by design. This is how it should be. Can you imagine the implications if a web site developer could add code to their page to "see" what other sites you have opened in your browser?
window.name is the only persistent data element you can use for this purpose, as described your requirements.
I want to notify only this page, even if user moves from this page.
This is impossible. Once a user navigates away from a page, you lose control over that tab. You can't push to a page, it needs to make a server request FROM that page, even if it's ajax.
Using sessionStorage. It supported by FF3.5+, Chrome4+, Safari4+, Opera10.5+, and IE8+.
For IE7 using "window.name" property.

Providing a back link inside of a Facebook tab

I'm trying to use history.back() inside of my Facebook app to go up our site hierarchy since the browser back button is obviously useless in this sort of situation. I'm using javascript to avoid having to manage history site on the backend but it's proving to be very buggy. Clicking a link with href="javascript:history.back()"causes the page to scroll around a couple times then actually causes top to go back...
Any help with this subject is greatly appreciated.
So it turns out that history.back() is not possible due to the way Facebook hacks around with the iframes that run apps. I ended up having to implement a pseudo-back link via an implementation in the server-side framework I was using.

add bookmark in Firefox without any dialog box

Using JavaScript, is it possible to add a bookmark in Firefox directly, without opening any dialog box? That is, I want the user clic on a link and that the bookmark is automatically created, without the need to any further step.
Fortunately, no. It would be a horrible breach of security.
Could be a different story in the context of a Firefox Extension, but I assume you are asking for a normal web page.
If it was possible, any possible website would be able to create any kind bookmark, without the user even noticing.
As a user, I certainly hope this is not possible ^^
(And, as a developper, I don't think it is)

Categories