我有一个网页,在onLoad中,使用jQuery创建锚标记列表 (外部javascript)。 (href和onclick事件也在那里定义)。
例如:
<a href="javascript:method1(1)" onclick="return method2(1);">Test1</a>
<a href="javascript:method1(2)" onclick="return method2(2);">Test2</a>
由于它是通过外部javascript文件创建的,我无法编辑此onLoad,也不能编辑method1的方法定义
现在我希望在medthod1完成后调用method3
。
任何帮助将不胜感激。
答案 0 :(得分:1)
您可以编写一个包装函数来同时调用:
<head>
<script>
function wrapperFunction(arg1, arg2){
method2(arg1);
method3(arg2);
}
</script>
</head>
<body>
<a href="javascript:method1(1)" onclick="wrapperFunction(1,2);">Test1</a>
...
答案 1 :(得分:1)
您可以在外部method2
创建锚点后覆盖js
,
在加载所有资源后,您可以使用load
标记的body
事件:
function window_load()
{
var newHandler = method2;
method2 = function(arg){
var result = newHandler(arg);
// ...
// you can call here any function or something else
// ...
return result;
};
}
我试图覆盖method2
,通过这种方法,您可以更改任何您想要的方法