search
HomeWeb Front-endJS TutorialLine breaks and automatic content extraction in online editors_javascript skills

Some use "return false" to solve the problem of inserting
in IE, but Firefox does not solve it. And this problem has not been solved even by fckeditor. Haha, I wonder if it was intentional.
Maybe after reading the above description, you still don’t understand the problem. Let’s do an experiment. Open fckeditor, switch to source code mode, enter

test test test test test test
, then switch back to design mode, and then enter an enter anywhere in this sentence, such as after the third test. , you will find that what you get in the source code is
test test test
test test test
, and if it is in the form of
, it will be automatically generated in this form, which will add a lot of useless code, and this problem exists in all online editors I can find.
Why do you have to use
for line breaks? Simple and flexible. Unlike

, which has a large space between blank lines, you only need to enter a few more carriage returns in large blank lines. And if you use automatic extraction of part of the article content, you are not afraid that the tag does not have a closure (maybe '
' should not be cut, but there is only a small amount of content and the display is abnormal. And the probability of '
' being cut is very low, unless Use multiple
in a row, which is easy to fix, of course). In this way, you can use

when using a custom layer. The advantage is that you are not afraid of being cut and the tag will not have closure. This avoids using

. If you use
to automatically intercept the content of the article and there is a
without closure (this situation is easy to happen if there is a lot of content in a div), it will have a bad impact on the effect of the entire page. Removing tags and then intercepting the content is not a good choice. For example, csdn's blog first removes the tags and then intercepts the article. Everyone has seen this effect, and it is definitely not good. Of course, if you want to ensure the integrity of the tag, such as img, a still has some work to do, it will be much simpler. Remember that after processing in this way, after intercepting the article content and storing it in the database, the
tag that the user may edit using the source code must be replaced with the

tag.
How can I get

test test test
test test test
?
Haha, the solution to the problem is actually very simple. That is to block the default action of the browser instead of returning false (this method can be found online, but this can only solve the problem under IE).
Use onkeydown event binding function (compatible with ie, firefox)
function cancelEnter (e)
{
var keyCode = e.charCode || e.keyCode;
if(keyCode == 13)
{
// Here use the insert character function plus
(of course it can be other) such as document.execCommand(cmd, false, '
');
// Note that IE does not support this command
// Since the implementation may be different in iframe or div code, it depends on your specific situation (to be compatible with IE, Firefox must also be compatible)
// You can also search on the Internet Not much to say when it comes to the code
if(e.preventDefault) e.preventDefault(); // Disable browser default actions (here is the key)
else e.returnValue = false;
}
}
This gives you
test test test
test test test
.
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
如何解决 Windows 11 中的文件名或扩展名过长的问题?如何解决 Windows 11 中的文件名或扩展名过长的问题?Apr 22, 2023 pm 04:37 PM

您在传输文件时是否遇到过任何问题,并且禁止您这样做?好吧,许多Windows用户最近报告说,他们在将文件复制并粘贴到文件夹中时遇到了问题,其中抛出了一个错误,提示“目标文件夹的文件名太长”。此外,其他一些Windows用户在打开任何文件时表示失望,并说“文件名或扩展名太长”,他们无法打开文件。这不允许他们将文件传输到任何其他文件夹,这让用户感到失望。在分析问题时,我们提出了一系列解决方案,可能有助于缓解问题,用户可以轻松传输文件。如果您也遇到类似情况,请参阅此帖子以了解更多信息。来源:https

如何在Windows 11、10中关闭Windows Defender智能屏幕?如何在Windows 11、10中关闭Windows Defender智能屏幕?Apr 26, 2023 am 11:46 AM

许多Windows用户最近报告说,当WindowsDefenderSmartScreen警告用户不要启动MicrosoftWindows无法识别的应用程序时,他们感到恼火,他们每次都必须单击“仍然运行”选项。Windows用户不确定他们目前可以做些什么来避免或禁用它。在研究了这个问题后,我们发现系统上的WindowsDefender功能可以通过设置应用程序或本地组策略编辑器或通过调整注册表文件来禁用。通过这样做,用户将不再需要面对防守者SmartScreen。如果您的系统也遇到

15 款 Python 编辑器/ IDE 详细攻略,总有一款适合你!15 款 Python 编辑器/ IDE 详细攻略,总有一款适合你!Aug 09, 2023 pm 05:44 PM

写 Python 代码最好的方式莫过于使用集成开发环境(IDE)了。它们不仅能使你的工作更加简单、更具逻辑性,还能够提升编程体验和效率。每个人都知道这一点。而问题在于,如何从众多选项中选择最好的 Python 开发环境。

修复 Windows 11/10 登录选项被禁用的问题修复 Windows 11/10 登录选项被禁用的问题May 07, 2023 pm 01:10 PM

许多Windows用户都遇到过由于登录尝试失败或多次关闭系统而无法登录Windows11/10系统的问题。用户很沮丧,因为他们对此无能为力。用户可能忘记了登录系统的PIN码,或者在使用或安装软件时出现卡顿,系统可能被多次强制关闭。因此,我们制定了一份最好的可用解决方案列表,这些解决方案无疑将帮助消费者解决这个问题。要了解更多信息,请继续阅读本文。注意:在此之前,请确保您拥有系统的管理员凭据和Microsoft帐户密码以重置PIN。如果没有,请等待一个小时左右,然后尝试使用正确的PIN

强烈推荐十个 Python IDE 和代码编辑器!强烈推荐十个 Python IDE 和代码编辑器!Apr 19, 2023 pm 07:04 PM

Python非常易学,强大的编程语言。Python包括高效高级的数据结构,提供简单且高效的面向对象编程。Python的学习过程少不了IDE或者代码编辑器,或者集成的开发编辑器(IDE)。这些Python开发工具帮助开发者加快使用Python开发的速度,提高效率。高效的代码编辑器或者IDE应该会提供插件,工具等能帮助开发者高效开发的特性。1.VimVim可以说是Python最好的IDE。Vim是高级文本编辑器,旨在提供实际的Unix编辑器‘Vi’功能,支持更多更完善的特

如何使用 ClipChamp:免费的 Windows 11 视频编辑器如何使用 ClipChamp:免费的 Windows 11 视频编辑器Apr 20, 2023 am 11:55 AM

还记得Windows7上的WindowsMovieMaker吗?自从停止WindowsMovieMaker以来,微软还没有推出任何真正的电影制作者。另一方面,他们尝试用一个小巧轻便的内置视频编辑器来改造照片应用程序。很长一段时间后,微软推出了Clipchamp,这是一款适用于所有Windows11设备的更好的视频处理器。在本文中,我们将深入探讨如何从Windows11设备上的Clipchamp应用程序中获取所有内容。如何使用Clipchamp–详细教程我们提供

Golang编辑器推荐:五个适合开发的选择Golang编辑器推荐:五个适合开发的选择Jan 19, 2024 am 09:00 AM

随着Golang的流行和普及,越来越多的开发者开始使用这门编程语言。然而,和其他流行的编程语言一样,Golang的开发需要选择一款适合的编辑器来提高开发效率。在本文中,我们将介绍五个适合Golang开发的编辑器。VisualStudioCodeVisualStudioCode(简称VSCode)是微软开发的一款免费的跨平台编辑器。它是基于Elect

如何在 Windows 11 和 10 上使用 Clipchamp 视频编辑器如何在 Windows 11 和 10 上使用 Clipchamp 视频编辑器Apr 17, 2023 pm 07:55 PM

如何在Windows上安装和使用ClipchampClipchamp应用程序尚未预装在Windows上,但这是未来的计划。同时,您需要先下载并安装Clipchamp。要在Windows11和Windows10上安装和使用Clipchamp:从MicrosoftStore下载并安装Clipchamp。安装后,在开始菜单中搜索Clipchamp以启动它。在Clipchamp窗口中,您需要使用您的Microsoft或Google帐户登录,或者使用您自己的个人电子邮

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),