javascript - document.write 未捕获语法错误

标签 javascript syntax-error document

document.write("<div id='MainDiv' style='width:600px;margin:auto;'>")

在浏览器中打开文件时出现如下错误

Uncaught Syntax Error: Unexpected token ILLEGAL

这个问题有什么解决办法吗?

最佳答案

试试这个:

document.write("<div id='MainDiv' style='width:600px;margin:auto;'>")

关于javascript - document.write 未捕获语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30507783/

相关文章:

php - 将 ajax 调用获取的数据返回到另一个函数

php - 功能导致脚本停止在PHP

C#/SQL 语法错误

node.js - Express:查询文档是否存在

php - PHP 中的 JavaScript 无法正常工作(document.getElementById)

MongoDB:文档、记录和属性之间有什么区别?

javascript - 将 URL 中的 HTML 内容插入 HTML(表单、div、iframe 等)

javascript - innerHTML 适用于 body 元素,但不适用于 p 元素

javascript - 在 Leaflet 中一起交互的过滤器

javascript - ReactJS 抛出语法错误