简体   繁体   中英

arguments.callee question

I know it's possible to call the calling function, but is it possible to call the function calling that function. Ok ... that sounds a little confusing. Let me demonstrate:

pop.share(msg, function(response) {
    if(response) response = true;
    else response = false;
});

Basically a box pops up to ask the user to share. If the response is false I want to call pop.share ... thus displaying the popup modal forcing them to share. Ok, this is probably not good logic or practice for a live site.

I was just lying in bed and I got a though "can that actually be done". I was trying and trying with some test code and couldn't figure it out.

Edit: A do while would not work if it was a modal as it's not waiting for the users response, thus creating an infinite loop.

Try obsolete arguments.caller ? But since it is obsolete, it is not useful for live site.

https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Functions_and_function_scope/arguments/caller

尝试不要过时的arguments.callee.caller

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM