tags:

views:

131

answers:

4

I have two browser tabs, tab1 and tab2.

I have a function called execute in tab1, which I would like to call from the page in tab2.

Is that possible and if so how?

+1  A: 

You should show your html in the first place, but i assume your tab has a link, you could do like this:

<a href="some-path" id="tab2">Tab 2</a>

JQuery:

$('#tab2').click(function(){
   // your function code here

  // prevent default action
  return false;
})
Sarfraz
A: 

I really cannot understand what you mean by the question.

But you can pass javascript function references as arguments to other functions.(Be wary of object execution contexts).

So while initializing "tab2", you could send in the function reference of execute of "tab1", to "tab2".

Could have given a more definitive answer with an example , had you been clearer in your question.

The Machine
my basic quetiosn is how to call a fucation in other window or other tab?
kumar
I am not aware of a way to do that !Isnt the javascript window object the parent-most object that we have at our disposal? How can you access the code in another window ?! (Violates the very principle of how a browser works, in my understanding)Can you explain your need a little more, I may be able to suggest a workaround .
The Machine
A: 

I pity your client.

-1, this is neither an answer nor is it helpful in any way.
0xA3
+5  A: 
scunliffe