🔄 JS / HTML 互转工具

JavaScript ↔ HTML 双向转换 | 脚本嵌入网页 | 从网页提取脚本

📝 转换方向

✨ 转换结果

结果
等待转换...

📖 使用说明

生成的 HTML 文件默认使用 UTF-8 编码,并包含基本文档结构,可直接保存为 .html 文件使用。

`; currentResultText = htmlTemplate; resultValueSpan.textContent = currentResultText; resultLabel.textContent = '转换结果(HTML 代码)'; currentResultType = 'html'; downloadBtn.style.display = 'inline-block'; downloadBtn.textContent = '下载 .html 文件'; } // HTML 转 JS(提取所有 script 内容) function htmlToJs() { let htmlCode = htmlInput.value.trim(); if (!htmlCode) { alert('请输入 HTML 代码'); return; } // 正则匹配所有