我打电话给之前已经创建的onclick。 该按钮已经有一个onclick,但我需要在提交之前添加一个参数。使用Javascript修改OnClick中的代码
这里的按钮上的查看源代码:
<td valign='top' align='right' >
<button name="Complete" title="Complete"
onClick="document.forms.Maker.action='http://mysite.com:8080/internal/Step.jsp?theId=19032&target=step20&type=Full';
document.forms.Maker.submit();return false;">Complete</button>
</td>
这是一个修改我发到用户按下按钮后,添加一个确认,我还添加了这样它显示什么的onclick目前有:
function addEventConfirmation(element, type){
var old = element['on' + type] || function() {};
element['on' + type] = function() {
if (confirm("Are you sure?")){
old.call(this);
alert(old);
} else { return false; }
};
}
这是警报从代码之前:
function onclick()
{
document.forms.Maker.action='http://mysite.com:8080/internal/Step.jsp?theId=19032&
target=step20&type=Full';document.forms.Maker.submit();return false;
}
的结果应显示是这样的:
function onclick()
{
document.forms.Maker.action='http://mysite.com:8080/internal/Step.jsp?theId=19032&
target=step20&type=Full&newParam=true';document.forms.Maker.submit();return false;
}
访问数据源这就是我想要做的,得到把Action变成一个变量。但是onclick对象不会让我将它转换为String。 – elcool 2011-03-30 16:24:02