Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- calling & defining functions using funcName() vs. window['funcName']()


sssweb - 6:45 pm on Jan 4, 2013 (gmt 0)


I sort of follow you, but now I get an error even when defining the function outside ready() as you suggest. Here's my code:

jQuery.noConflict();

(function () {
var $ = jQuery;
function test() {
alert("window call / normal def");
$("#test2").fadeOut(1000);
}
})();

jQuery(document).ready(function($) {
window["test"]();
});

I get the error whether the call is w/in ready() or not; the error is: Object doesn't support property or method 'test'.


Thread source:: http://www.webmasterworld.com/javascript/4533285.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com