回复 12楼study1990的帖子
应该是在Spread还没有加载完成时访问了Spread对象,可以判断readyState来控制代码流程:
- <script language="javascript" type="text/javascript">
- $(document).ready(function () {
- //设定编辑框焦点
- var ss = FpSpread("ReportTemplate");
- if (document.all) {
- var browser = navigator.appName;
- var b_version = navigator.appVersion;
- var version = b_version.split(";");
- var trim_Version = version[1].replace(/[ ]/g, ""); //MSIE8.0; MSIE9.0
- if (browser == "Microsoft Internet Explorer" && trim_Version.substr(4) >= 9) {
- if (ss.SetActiveCell)
- ss.SetActiveCell(0, 0);
- if (ss.SetSelectedRange)
- ss.SetSelectedRange(0, 0, 1, 1);
- }
- else if (browser == "Microsoft Internet Explorer" && trim_Version.substr(4) <= 8) {
- SetAC();
- // if (ss.SetActiveCell() != null && ss.SetActiveCell() != undefined)
- // ss.SetActiveCell(0, 0);
- // if (ss.SetSelectedRange() != null && ss.SetSelectedRange() != undefined)
- // ss.SetSelectedRange(0, 0, 1, 1);
- // ss.Update();
- }
- }
- else {
- ss.SetActiveCell(0, 0);
- ss.SetSelectedRange(0, 0, 1, 1);
- }
- });
- function SetAC() {
- var spread = FpSpread("ReportTemplate");
- if (spread.readyState == "loading") {
- setTimeout(SetAC, 500);
- } else {
- if (spread.SetActiveCell() != null && spread.SetActiveCell() != undefined)
- spread.SetActiveCell(0, 0);
- if (spread.SetSelectedRange() != null && sspreads.SetSelectedRange() != undefined)
- spread.SetSelectedRange(0, 0, 1, 1);
- spread.Update();
- }
- }
- </script>
复制代码 |