Html code button

   <!DOCTYPE html>

<html>

<head>

    <title>Text Editor with Copy Button</title>

    <style>

        textarea {

            width: 100%;

            height: 200px;

            resize: none;

        }

    </style>

</head>

<body>


<textarea id="editor">

</textarea><br>


<button onclick="copyText()">Copy</button>

<button onclick="run()">Run</button><br>


<iframe id="preview" width="100%" height="300px" frameborder="0"></iframe>


<script>

    function copyText() {

        var editor = document.getElementById("editor");

        editor.select();

        document.execCommand("copy");

        alert("Text copied to clipboard!");

    }


    function run() {

        var editorContent = document.getElementById("editor").value;

        var iframe = document.getElementById("preview").contentDocument;

        iframe.open();

        iframe.write(editorContent);

        iframe.close();

    }

</script>


</body>

</html>


No comments:

Post a Comment