我可以解释我的问题,但演示它可能更容易......
如果你看看http://jsfiddle.net/XxT2B/你会看到我的问题。我无法弄清楚如何将动作传递给函数。你会明白我的意思。
请注意,根据调用函数的内容,操作可能会有所不同。该动作可能是按时发出警报,而下一次发出不同的警报。
这是我的代码...
function abc(action)
{
//Do a bunch of stuff first and then do the action sent to this function
alert('This function is named "abc"');
//This is the part I do not know how to do.
//The action might be an alert or something totally different so I can't just pass text
//I need to know how to execute the action passed.
action;
}
abc('alert("I like pizza")');