DEV Community

Cover image for Cara Membuat HTML Editor di Blog dengan Mudah dan Responsive
AWDEV
AWDEV

Posted on

1

Cara Membuat HTML Editor di Blog dengan Mudah dan Responsive

Cara Membuat HTML Editor di Blog dengan Mudah dan Responsive

Awgroupchannel- Dalam membangun sebuah blog, terkadang kita memerlukan yang namanya HTML Editor, entah itu untuk melakukan demo artikel atau kita gunakan untuk menguji coba script yang kita buat. Sebenarnya apa sih HTML Editor itu? HTML editor adalah sebuah form yang digunakan untuk melihat hasil atau output dari sebuah kode HTML. Sebenarnya sudah banyak website yang menyediakan HTML editor secara online. Tapi jika kita bisa membuat sendiri kenapa harus membuka web orang lain?

Dengan membuat HTML editor di blog kita, hal tersebut juga berpotensi menambah visitor blog kita. Dikarenakan banyak sekali blogger yang memerlukan HTML editor ini sehingga HTML editor ini banyak yang mencari. Apabila HTML editor kita berada di Page One, tentu kita akan mendapatkan benyak pengunjung dari situ. Lalu bagaimana sih cara membuat HTML editor diblog dengan mudah?

  1. Pertama, kalian masuk dulu ke dashboard blogger anda.
  2. Setelah itu buat halaman baru, dengan cara klik Halaman -> Halaman Baru -> HTML

  3. Pastekan kode diini pada kotak HTML yang telah disediakan

<!DOCTYPE html>

HTML Editor Preview <!-- Copyright (c) 2021, Aw Score Code - AL HIKMAH [ Desain by : Aw Group Channel ] All rights reserved. For licensing, see LICENSE.html or https://kata-h.blogspot.com/p/license.html--> <!-- Copyright (c) 2021, Aw Score Code - Desain by : Aw Group Channel All rights reserved. For licensing, see LICENSE.html or https://www.awgroupchannel.my.id/p/license.html --> var $ = function(el) { return document.querySelector(el); }; function updatePreview(html) { $(&#39;#preview-frame&#39;).contentWindow.document.open(); $(&#39;#preview-frame&#39;).contentWindow.document.write(html); $(&#39;#preview-frame&#39;).contentWindow.document.close(); } $(&#39;#code-editor&#39;).addEventListener(&#39;input&#39;, function(e) { updatePreview(this.value); }); window.addEventListener(&#39;beforeunload&#39;, function(e) { if (e) { // Cancel the event e.preventDefault(); // Chrome requires returnValue to be set e.returnValue = &#39;&#39;; } return &#39;Are you sure want to exit?&#39;; }); var $ = function(el) { return document.querySelector(el); }; function updatePreview(html) { $(&#39;#preview-frame&#39;).contentWindow.document.open(); $(&#39;#preview-frame&#39;).contentWindow.document.write(html); $(&#39;#preview-frame&#39;).contentWindow.document.close(); } window.addEventListener(&#39;beforeunload&#39;, function(e) { if (e) { // Cancel the event e.preventDefault(); // Chrome requires returnValue to be set e.returnValue = &#39;&#39;; } return &#39;Are you sure want to exit?&#39;; }); window.addEventListener(&#39;DOMContentLoaded&#39;, function(e) { cm = CodeMirror.fromTextArea($(&#39;#code-editor&#39;), { lineNumbers: true, styleActiveLine: true, mode: &#39;text/html&#39;, theme: &#39;monokai&#39; }); cm.on(&#39;change&#39;, function() { updatePreview(cm.getValue()); }); updatePreview(cm.getValue()); }); html { height: 100%; } { margin: 0; padding: 0; } body { font-family: &quot;Georgia&quot;, &quot;Arial&quot;, &quot;Serif&quot;; width: 100%; position: relative; min-height: 100%; box-sizing: border-box; height: 100%; color: #999; background-color: #272822; } h2.title { display: block; width: 100%; padding: 0.5em 0.5em 0.5em 1em; font-size: 1.2em; font-weight: normal; box-sizing: border-box; } .text-center { text-align: center; } .hide { display: none; } .border-bottom { border-bottom: 1px solid #333; } .editor, .preview { height: 100%; width: 100%; position: relative; box-sizing: border-box; } .editor #code-editor { margin: 0; padding: 0; width: 100%; height: 100%; background-color: #f1f1f1; font-family: monospace; font-size: 18px; } .preview #preview-frame { height: 100%; width: 100%; border: none; background-color: #FFFFFF ; } @media screen and (min-width: 720px) { .editor { width: 50%; float: left; padding-bottom: 0; } .menu { width: 300px; border-right: 1px dotted #999; border-bottom: 1px dotted #999; } .preview { width: 50%; float: left; } .full-width { width: 100%; float: initial; } } logo .navi{ width:100px; height:100px; position:nav; bottom:0px; right:0px; z-index:100; } logo <!-- EDITOR WINDOW -->

HTML Editor

<!DOCTYPE html> Contoh HTML EDITOR Contoh HTML EDITOR <!-- Copyright (c) 2021, Aw Score Code - Desain by : Aw Group Channel All rights reserved. For licensing, see LICENSE.html or https://www.awgroupchannel.my.id/p/license.html --> SPONSOR[ ] <!-- PREVIEW WINDOW -->

Preview

<!-- Copyright (c) 2021, Aw Score Code - Desain by : Aw Group Channel All rights reserved. For licensing, see LICENSE.html or https://www.awgroupchannel.my.id/p/license.html --> Desain by Aw Group Channel <!-- Copyright (c) 2021, Aw Score Code - Desain by : Aw Group Channel All rights reserved. For licensing, see LICENSE.html or https://www.awgroupchannel.my.id/p/license.html -->
Home

Sumber Code : https://github.com/wahyu9kdl/Aw-Creative/blob/main/CODE.html

Bagaimana? Cukup mudah bukan cara membuat HTML editor diblog. Sekarang anda tidak perlu membuka web lain untuk menggunakan HTML editor dikarenakan blog kita sudah memilikinya sendiri. Terimakasih telah berkunjung di Awgroupchannel. Salam .

Terimakasih.

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools can’t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay