【问题标题】:Missing semicolons in JavaScriptJavaScript 中缺少分号
【发布时间】:2016-03-09 08:50:09
【问题描述】:

我对 JavaScript 不太认可,但我需要包括我的 标头到我的 HTML。我们有工作场所提供的联系表格,需要在我的标题中暗示。

但我一直有一个缺少分号的错误,我不知道它在哪个地方。

function writeHeader(){
    var html = "";
    html += '<header>';
    html += '<p class="fL mr15"><a href="javascrip:openWin('002','10100');"><img src="images/head_btn01.png" alt="contact" class="opacity"></a></p>';
    html += '</header>';

    document.write(html);
}

这部分实际上不起作用:&lt;a href="javascrip:openWin('002','10100');"&gt;

【问题讨论】:

  • javascrip 是一个错字...
  • javascrip:openWin('002','10100'); 看到了吗?脚本?此外,我们不知道是否定义了 openWin(在这种情况下,' 应该被转义)
  • 很抱歉。这是openWin的js
  • 函数 openWin(rShohincd,rShozokucd){ document.frm01.hidShohincd.value = rShohincd; document.frm01.hidShozokucd.value = rShozokucd; wx = 660; wy = 650; x = (screen.width - wx) / 2; y = (screen.height - wy) / 2; winShozoku = window.open('','WindowP','left='+x+',top='+y+',width='+wx+',height='+wy+',menubar=no,location=no,目录=否,滚动条=是,工具栏=否,状态=否,可调整大小=否'); winShozoku.focus(); document.frm01.method = '发布'; document.frm01.target = 'WindowP'; document.frm01.action = 'purai.asp'; // document.frm01.action = 'purai.asp'; document.frm01.submit(); }

标签: javascript syntax-error


【解决方案1】:

您需要转义字符串中的单引号:

改变这个:

javascrip:openWin('002','10100')

致此:

javascript:openWin(\'002\',\'10100\')

您还拼错了“javascript”。

【讨论】:

  • 嗨,感谢您的更正。但它仍然不起作用>
  • 您能否提供有关该问题的更多详细信息?函数执行后,您是否在浏览器控制台中看到任何错误?顺便说一句,请确保正在调用该函数。
  • 当我尝试执行你的函数时,控制台中没有写错误。
  • 您在哪里看到此错误“缺少分号”?它是否告诉错误发生在哪一行?
  • 这是openWin的js
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多