开发者

Hook a function in place of existing function in javascript

开发者 https://www.devze.com 2023-02-16 11:34 出处:网络
I am trying to override one function by replacing it with a different version. The function which I am trying to override is defined in a web resource of a control. But, I have tried the same for scri

I am trying to override one function by replacing it with a different version. The function which I am trying to override is defined in a web resource of a control. But, I have tried the same for script resources, it works.

function HookCalendarFunction() {
    try {
        var Original_performLayout = _performLayout;
        _performLayout = function () {
            performLayout();
        };
        var Original_cell_onclick = _cell_onclick;
        _cell_onclick = function (val) {
            cellClick(val);
        };
    }
    catch (e) {

    }

}

Here, _performLayout is a function for a custom control in ASP.net. _performLayout is in web res开发者_运维知识库ources of the control.

Thanks Ashwani


Check _performLayout is global and your that declaration happens after the original declaration.


I solved the issue, the issue was with the scope of function.

0

精彩评论

暂无评论...
验证码 换一张
取 消