我试图确定是否可以执行execCommand('undo').
我试过这个:
if(document.execCommand('undo'))
{
document.execCommand('redo');
// some code
}
Run Code Online (Sandbox Code Playgroud)
它的工作原理......但它让我在脚本的其他部分遇到了一些问题.
还有另一种方法可以查看"撤消"是否可执行?
提前致谢!
我目前使用的代码很难看,因为我必须为每个特殊字符单独写"替换".
var str = ":''>";
str.replace("'","\\'").replace(">","\\>");
Run Code Online (Sandbox Code Playgroud)
我想将反斜杠添加到<>*()和?通过正则表达式.
我正在使用img标签替换我的文本编辑器中的笑脸快捷方式,但我使用的逻辑也将链接和标签的部分视为笑脸快捷键(例如:/在http://中,或者:p在游标中:指针在风格中属性)
如何在用图像替换笑脸快捷方式时忽略所有链接和html标记?
for(var key in shortcuts){
// Check if the editor html contains the looped shortcut
if(content.toLowerCase().indexOf(key) != -1){
// Escaping special characters to be able to use the shortcuts in regular expression
var k = key.replace(/[<>*()?']/g, "\\$&");
// Make shortcuts case insensitive
var regex = new RegExp(k, "ig");
//Replace shortcuts with img tags (smileys)
tinymce.activeEditor.setContent(content.replace(regex,'<img src="images/transparent.png" class="smiley_icon '+ shortcuts[key] +'">'));
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用.htaccess.
我原来的链接是:
http://example.com/CareerDays/index.php?u_type=admin
Run Code Online (Sandbox Code Playgroud)
而我正试图让它看起来像这样:
http://example.com/v/admin
Run Code Online (Sandbox Code Playgroud)
整个代码如下所示:
RewriteEngine On
RewriteRule ^v/([^/]*)$ /CareerDays/index.php?u_type=$1 [L]
Run Code Online (Sandbox Code Playgroud)
我总是得到
" 500内部服务器错误 "
我有一个看起来像这样的字符串:
var str = "Hello world, hello >world, hello world!";
Run Code Online (Sandbox Code Playgroud)
......我想用地球替换所有的hellos,例如bye和world,除了以 或>开头的单词.那些应该被忽略.所以结果应该是:
bye earth, hello >world, bye earth!
Run Code Online (Sandbox Code Playgroud)
试过这个
str.replace(/(?!\ )hello/gi,'bye'));
Run Code Online (Sandbox Code Playgroud)
但它不起作用.