gpt4 book ai didi

javascript - nicEdit 面板不出现

转载 作者:行者123 更新时间:2023-12-03 07:40:11 24 4
gpt4 key购买 nike

我正在使用 nicEdit 作为本地站点的记事本编辑器。我使用复选框来调用 nicEdit 函数(注释),但面板根本不显示。甚至警报也没有出现。

还有其他三个函数可以使用 cookie 保存笔记:

//annotation 
function annotation(player1) {
bkLib.onDomLoaded(function(){
new nicEditor({
fullPanel : true,
onSave : function(content, id, instance) {
var player_name = document.getElementById('player1').value;
alert(player_name);
checkCookie(player_name);
setCookie(content,player_name);
}
}).panelInstance('myArea');
});
}

function setCookie(content,player) {
var d = new Date();
d.setTime(d.getTime() + (365*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = player + "=" + content + "; " + expires;
}

//check if the coockie with current player name exists
function checkCookie(player_name) {
var pnote = getCookie( player_name );
//alert(pnote);
if ( pnote!="" ) {
$(".nicEdit-main").append(pnote);
} else {
if ( player_name != "" && player_name != null ) {
$(".nicEdit-main").append("");
alert("nothing");
}
}
}

//Gets the cookie content
function getCookie(player_name) {
var name = player_name + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return "";
}
<textarea style="height: 300px;" cols="52" id="myArea" name="myArea" style="width:450px; " ></textarea>
<input type="checkbox" onclick="annotation(player1)" id="player1" value="player1">player1 <br>

最佳答案

好吧,打电话

bkLib.onDomLoaded(function(){}

你的注释函数是错误的。

这是使用jquery处理点击事件的方法。

$('#player1').click(function () {
alert("player");
new nicEditor({
fullPanel : true,
onSave : function(content, id, instance) {
var player_name = document.getElementById('player1').value;
alert(player_name);
checkCookie(player_name);
setCookie(content,player_name);
}
}).panelInstance('myArea');
});

jsfiddle 的完整示例 https://jsfiddle.net/cqcu0hbp/

关于javascript - nicEdit 面板不出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35443899/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com