0

I have a page that loads few iframe's within itself. Each iframe can invoke parent function. For example like this:

$(document).ready(function() {
  parent.test();
}

I want to be able to find which iframe invoked test function. I've tried to play with calleer.called properties but the best I could get is the function that calling test(). In my case it was $(document).ready function. Is there a way to get the name of iframe (or it's html name) which calling the function?

JustAHate
  • 43
  • 5

1 Answers1

0

If you pass a parameter to the test function it will work:

$(document).ready(function() {
  parent.test('name of this iframe');
}

OR even better

$(document).ready(function() {
  parent.test(window.name);
}

Then you just need to use that value passed to the inside of the test function.

Sergio
  • 28,539
  • 11
  • 85
  • 132
  • Yes, this will definitely work but that not exactly what I want. I want to get iframe name (or filename) without passing an argument. – JustAHate Jul 29 '13 at 08:44
  • @user2629489, maybe you are looking for this http://stackoverflow.com/questions/280389/how-do-you-find-out-the-caller-function-in-javascript/3789144#3789144 – Sergio Jul 29 '13 at 08:47