所以我试图制作一个ui来制作html窗口元素,当我运行这个脚本时,这就是错误出现的情况。我在chromebook上的chrome浏览器上运行它。
Javascript jquery.min.js:2 Uncaught SyntaxError:意外的令牌<
function createwindow(settings) {
var draggableclass = "";
if (settings == undefined) {
var settings = {};
}
if (settings.content == undefined) {
settings.content = "";
}
if (settings.closecolour == undefined) {
settings.closecolour = "#ffffff";
}
if (settings.requirejs == undefined) {
settings.requirejs = "";
}
if (settings.windowcolour == undefined) {
settings.windowcolour = "#000000";
}
if (settings.width == undefined) {
settings.width = 200;
}
if (settings.height == undefined) {
settings.height = 400;
}
if (settings.appname == undefined) {
settings.appname = "Untitled App";
}
if (settings.bodycolour == undefined) {
settings.bodycolour = "#ffffff";
}
if (settings.icon == undefined) {
settings.icon = "http://www.iconarchive.com/download/i45241/iconleak/stainless/script.ico";
}
if (settings.titlecolour == undefined) {
settings.titlecolour = "#ffffff";
}
var requirejs = '';
var appname = settings.appname.replace(" ", "-");
var closexy = settings.width - 14;
closexy = settings.width - 24;
draggableclass = "draggable";
var appid = '"#' + appname + '"';
var app = "<div style='border-style:solid;border-width:1px;border-bottom-width:26px;border-color:#000000;width:" + settings.width + "px;height:" + settings.height + "px;' id='" + appname + "' class='app'><div class='top " + draggableclass + "' style='width:" + settings.width + "px;background-color:" + settings.windowcolour + ";height:25px;'><img style='height:24px; width:24px;' src='" + settings.icon + "' /><text style='position:absolute;top:3px;color:" + settings.titlecolour + ";'>" + settings.appname + "</text><i style='color:" + settings.closecolour + ";position:absolute;left:" + closexy + ";' class='material-icons icon icon-button close-button' onclick='$(" + appid + ").remove()'>close</i></div><div style='background-color:" + settings.bodycolour + ";height:100%;width:100%;overflow:scroll;' class='innerapp'>" + settings.content + "</div></div>";
$('body').append(app);
$("#" + appname).draggable();
if (settings.length > 0) {
}
requirejs = settings.requirejs;
var nstr = requirejs.split("|");
if (nstr.length == 1) {
$(function () {
$('<' + 'script' + '>')
.attr('src', nstr[0])
.appendTo('head');
});
}
else if (nstr.length == 2) {
$(function () {
$('<' + 'script' + '>')
.attr('src', nstr[0])
.appendTo('head');
});
$(function () {
$('<' + 'script' + '>')
.attr('src', nstr[1])
.appendTo('head');
});
}
else if (nstr.length == 3) {
$(function () {
$('<' + 'script' + '>')
.attr('src', nstr[0])
.appendTo('head');
});
$(function () {
$('<' + 'script' + '>')
.attr('src', nstr[1])
.appendTo('head');
});
$(function () {
$('<' + 'script' + '>')
attr('src', nstr[2])
.appendTo('head');
});
}
else if (nstr.length == 4) {
$(function () {
$('<' + 'script' + '>')
.attr('src', nstr[0])
.appendTo('head');
});
$(function () {
$('<' + 'script' + '>')
.attr('src', nstr[1])
.appendTo('head');
});
$(function () {
$('<' + 'script' + '>')
.attr('src', nstr[2])
.appendTo('head');
});
$(function () {
$('<' + 'script' + '>')
.attr('src', nstr[3])
.appendTo('head');
});
}
}
function codemirroraddon(addon) {
var script = "<script src='codemirror/addon/" + addon + "'></script>";
$("head").append(script);
}
function codemirroraddoncss(addon) {
var css = "<link rel='stylesheet' href='codemirror/addon/" + addon + "' />";
$("head").append(css);
}
function injectjs() {
var userinput = jseditor.doc.getValue();
var script = document.createElement("script");
script.innerHTML = "" + userinput;
document.head.appendChild(script);
}