【问题标题】:I keep getting SCRIPT1014: Invalid character LINE1 AND CHARACTER1 when i try opening in IE9 [duplicate]当我尝试在 IE9 中打开时,我不断收到 SCRIPT1014: Invalid character LINE1 AND CHARACTER1 [重复]
【发布时间】:2013-01-07 21:57:57
【问题描述】:

可能重复:
SCRIPT1014: Invalid character

我的 HTML 代码是

<html>

<head>

<style type="text/css">
#p1 span {
width: 65px;
display: block;
float: left;
}

</style>

</head>

<body>

<script charset="UTF-8"      src="C:\Users\Chris\Documents\Projects\HTML_XML_JAVASCRIPT\jscodeloginpage.js"></script>

<h1 style="text-align:center;" STYLE="font-family:verdana;">FDM Markets</h1>
<h2 style="text-align:center;">Trading Platform</h2></br>

<p1>Login</p1></br>
</br>

<form name="anyForm">
Username: 
<input type="text" name="anyName" size="15" onKeyUp="Complete(this, event)">
</br>
Password: <input type="text" size="15" name="password_box">
</form>

<span id="clock" style=font-size: 12">&nbsp;</span>

</body>

</html>

我单独的 js 文件是

function Complete(obj, evt) {

var names = new Array("albert","alessandro","chris");
    names.sort();

if ((!obj) || (!evt) || (names.length == 0)) {
    return;
}

if (obj.value.length == 0) {
    return;
}

var elm = (obj.setSelectionRange) ? evt.which : evt.keyCode;

if ((elm < 32) || (elm >= 33 && elm <= 46) || (elm >= 112 && elm <= 123)) {
    return;
}

var txt = obj.value.replace(/;/gi, ",");
elm = txt.split(",");
txt = elm.pop();
txt = txt.replace(/^\s*/, "");

if (txt.length == 0) {
    return;
}

if (obj.createTextRange) {
    var rng = document.selection.createRange();
    if (rng.parentElement() == obj) {
        elm = rng.text;
        var ini = obj.value.lastIndexOf(elm);
    }
} else if (obj.setSelectionRange) {
    var ini = obj.selectionStart;
}

for (var i = 0; i < names.length; i++) {
    elm = names[i].toString();

    if (elm.toLowerCase().indexOf(txt.toLowerCase()) == 0) {
        obj.value += elm.substring(txt.length, elm.length);
        break;
    }
}

if (obj.createTextRange) {
    rng = obj.createTextRange();
    rng.moveStart("character", ini);
    rng.moveEnd("character", obj.value.length);
    rng.select();
} else if (obj.setSelectionRange) {
    obj.setSelectionRange(ini, obj.value.length);
        }
}


function tick() {

  var hours, minutes, seconds, ap;
  var intHours, intMinutes, intSeconds;
  var today;

  today = new Date();

  intHours = today.getHours();
  intMinutes = today.getMinutes();
  intSeconds = today.getSeconds();

  switch(intHours){

case 0: 

  intHours = 12;
      hours = intHours+":";
      ap = "A.M.";
      break;

case 12:

  hours = intHours+":";
      ap = "P.M.";
      break;

case 24:

  intHours = 12;
      hours = intHours + ":";
      ap = "A.M.";
      break;

default: 

  if (intHours > 12)

    {
        intHours = intHours - 12;
        hours = intHours + ":";
        ap = "P.M.";
        }

  if(intHours < 12)

   {
       hours = intHours + ":";
       ap = "A.M.";
       }

   break;

  } 

  if (intMinutes < 10) {
    minutes = "0"+intMinutes+":";
  } 

  else {
    minutes = intMinutes+":";
  }

  if (intSeconds < 10) {
    seconds = "0"+intSeconds+" ";
  } 

  else {
    seconds = intSeconds+" ";
  } 

  timeString = hours+minutes+seconds+ap;

  document.getElementById("clock").firstChild.nodeValue = timeString;

  window.setTimeout("tick()", 100);

  }

  window.onload=tick;

当我尝试在 IE9 中打开 html 文件时,控制台中出现错误并显示:SCRIPT1014: Invalid character LINE1 AND CHARACTER1 该代码适用于 Google Chrom tho IE9怎么不行?

【问题讨论】:

  • apache 会做什么,并给我一个下载链接,谢谢

标签: javascript internet-explorer-9 ie-developer-tools


【解决方案1】:

在您的代码示例中,我没有看到您的起始 html 标记。这可能是您出错的原因吗?

【讨论】:

  • 它在那里,但你没有看到它,因为代码在帖子中的格式不正确。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-05-05
  • 1970-01-01
  • 1970-01-01
  • 2021-03-29
  • 2014-05-03
  • 2021-01-28
  • 2021-11-30
相关资源
最近更新 更多