我在Salesforce应用程序中使用java-script而且我处于一种奇怪的情况。
我在visualforce页面中使用了以下代码。
<script>
var previousOnLoad = window.onload;
window.onload = function() {
if (previousOnLoad) {
previousOnLoad();
}
renderSection('false');
setFocus();
}
function setFocus() {
document.getElementById("{!$component.thePageBlock.state}").focus()
}
function renderSection(input) {
if (input == true) {
document.getElementById("{!$component.thePageBlock.theSection}").style.display='block';
}
}
</script>
我面临的问题是在调用setFocus()
函数后,未调用其他函数rendersection()
。但是当我删除setFocus()
然后尝试时,则调用rendersection()
。如上面的代码所示,我也尝试在rendersection()
之前提供setFocus()
。它还行不通。有谁知道我在这里遗失了什么?
此外,当我尝试将setFocus()更改为与putFocus或getFocus不同的函数时,将调用该函数,但焦点未设置为所需的字段。
由于