0

私はjsに非常に慣れていないので、助けていただければ幸いです。同じように動作すると思われるコード ブロックが 2 つありますが、動作しません。誰かがどのように違うのか説明できますか? コードの最初の部分では、パーサーが関数に直接入っているようです。

function embedGameSwfAfterReg() {
    embedGameSwf("{$swfLocation}", "100%", "100%", {$flashVars});
}
API.registerOnload(embedGameSwfAfterReg())

API.registerOnload(function() {
    embedGameSwfAfterReg("{$swfLocation}", "100%", "100%", {$flashVars});
});
4

6 に答える 6

2

In the first code block, you're registering the result of the embedGameSwfAfterReg function (undefined) as the onload function (() means you're evaluating the function). Remove the parentheses to have the embedGameSwfAfterReg function itself registered:

API.registerOnload(embedGameSwfAfterReg)
于 2013-06-14T17:30:22.930 に答える