有没有人知道我可以调用哪个javascript函数来激活此id上的'dblClickField'事件而不实际点击该框?这是一个复选框,我想用javascript强制通过控制台勾选它。
<td
class="dataCol inlineEditWrite"
id="00N200000030rph_ilecell"
onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"
onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);"
ondblclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.dblClickField(event, this);"
onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);"
onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);"
onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"
onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);"
tabindex="0">
<div id="00N200000030rph_ileinner">
<img src="/img/checkbox_unchecked.gif" alt="Not Checked" width="21" height="16" class="checkImg" id="00N200000030rph_chkbox" title="Not Checked">
</div>
</td>
答案 0 :(得分:0)
您可以致电apply
来完成此操作,如此答案:
但是,您可能需要考虑稍微不同的方法。只需将双击处理程序放在函数中:
function onDoubleClick() {
if (window.sfdcPage && window.sfdcPage.hasRun)
sfdcPage.dblClickField(event, this);
}
然后您可以从<td>
元素中引用它:
<td ondblclick="onDoubleClick();"...
在其他任何地方你也需要调用它。
这是一个证明:http://jsfiddle.net/nq5aP/
的jsfiddle答案 1 :(得分:0)
不要在HTML中添加如此多的内联代码。这不是很容易阅读。将您的代码放在一个函数中,然后您可以随时调用它(不会欺骗双击事件):
<script>
function dblclickfunction(event)
{
if (window.sfdcPage && window.sfdcPage.hasRun)
sfdcPage.dblClickField(event, this);
}
</script>
<td
class="dataCol inlineEditWrite"
id="00N200000030rph_ilecell"
onblur="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"
onclick="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.clickField(event, this);"
ondblclick="dblclickfunction(event);"
onfocus="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);"
onkeypress="if (window.sfdcPage && window.sfdcPage.hasRun && event && event.keyCode==KEY_ENTER) sfdcPage.dblClickField(event, this);"
onmouseout="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOutField(event, this);"
onmouseover="if (window.sfdcPage && window.sfdcPage.hasRun) sfdcPage.mouseOverField(event, this);"
tabindex="0">
<div id="00N200000030rph_ileinner">
<img src="/img/checkbox_unchecked.gif" alt="Not Checked" width="21" height="16" class="checkImg" id="00N200000030rph_chkbox" title="Not Checked">
</div>
</td>