Access javascript functions in an opened page in a tab from another page in another tab both pages same domain

6 views
Skip to first unread message

Rafa

unread,
Aug 30, 2017, 1:01:52 PM8/30/17
to Angular and AngularJS discussion
Starting from two pages in the same domain open in different tabs or browser windows.

Starting from two pages in the same domain open in different tabs or browser windows.


Can I access functions on one page from the other. 
That is, pass parameters to the functions of a page from the other and execute them? How could this be done ?. 


I do not need the execution of those functions to return results to the other page, just execution.


My first idea to do this is to use the localstorage object of HTML5 knowing that events can be executed in an open page  when changing the value of any variable of the localstorage by other page under the same domain. 
The page that hears these changes in localstorage can execute events and use the new values ​​assigned to the variable which would be equivalent to executing functions with params.


Is there any other way to do this?
Have functions within a page that can be executed from another page?

Thanks in advance


Sander Elias

unread,
Aug 31, 2017, 1:52:14 AM8/31/17
to Angular and AngularJS discussion
Hi Rafa,

For now, local-storage is the only true cross-browser solution. If you stack includes a server, you can use WebSockets. This allows you to communicate between more as just tabs on the same computer.  Another alternative is webrtc peer-to-peer, you don't need a server for this. 
When only targeting the local computer cross-tabs on the same browser, you can also use service-worker.  
There are a few more, but the ones I mentioned all have good browser support.   

Regards
Sander

Rafa

unread,
Aug 31, 2017, 4:46:11 AM8/31/17
to Angular and AngularJS discussion
I am very grateful for your answer, you have put on the table a lot of possible solutions to investigate when I only saw practically the one of the Localstorage. 

This is precisely what I needed, a broad and general view of the landscape of such communications.

Thank you Sander.
Reply all
Reply to author
Forward
0 new messages