[英]writing script in vf page
there is a req where 'lookup' window have to open automatically when page loads, so I used the below code. 有一个要求,当页面加载时,“查找”窗口必须自动打开,因此我使用了以下代码。 It is working fine in Chrome and firefox but not in IE.
它在Chrome和firefox中工作正常,但在IE中却不能。
Here is the vf page: 这是vf页面:
<apex:page standardController="Contact" id="page">
<script type='text/javascript'>
window.onload=function() {
var l = document.getElementById('page:form1:acc_lkwgt');
// document.getElementById('page:form1:acc_lkwgt').click();
l.click();
}
</script>
The problem that window.onload javascript is working in different way in IE. window.onload javascript在IE中以不同方式工作的问题。 Instead of this you should either use jQuery, or rewrite script in such way:
替代此方法,您应该使用jQuery或以这种方式重写脚本:
<script type="text/javascript">
function doLoad() {
var l = document.getElementById('page:form1:acc_lkwgt');
l.click();
}
if ( window.addEventListener ) {
window.addEventListener( "load", doLoad, false );
}
else
if ( window.attachEvent ) {
window.attachEvent( "onload", doLoad );
} else
if ( window.onLoad ) {
window.onload = doLoad;
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.