把 网页代码 嵌入到 单片机程序中,2024/7/25 17:33

把 网页代码 嵌入到 单片机程序中

                废话不多说直接上结果:

                        代码中定义:

                        const char* html="  处理过的网页代码  " ;

                        处理网页代码的 web 程序( 主要是 正则 把双引号 加 符号)

<!DOCTYPE html>
<html lang="en" style="background-color: rgba(9, 232, 24, 0.403);">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网页代码添加转义符小工具</title>
</head>

<body>
    <div id="daima" style="width: 100%;height: 30em;border: 2px solid aqua;overflow-y: auto;background-color: bisque;" contenteditable="true">

    </div>
    <button id="but" onclick="zy()" style="background-color: rgb(2, 120, 159);width:100%;height: 50px;"onmouseover="this.style.backgroundColor='lightblue';" 
    >转换</button>
    <script>function zy() {
            document.getElementById('but').style.backgroundColor = 'red';
            let hq = document.getElementById('daima').textContent;//获取代码
            let zh = hq.replace(/"/g, '\\"');//查找字符串 hq 中的所有双引号,并将它们替换为转义后的双引号(即 \")。
            document.getElementById('daima').innerText=zh;


        }</script>
</body>

</html>

 

效果展示 :

处理前:

处理后: 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值