수평선1203

건의사항이에요.

전체 게시판을 통합해서 보는 통합게시판기능이 있었으면 좋겠어요.

꾸벅꾸벅!!!

 

추가로 생성형 ai처럼 코드 실행기능도 추가부탁드려요.

많이 어렵지 않아 보여서요.

 

딥씨크

2022631670_1741005043.9515.png

쳇지피티

2022631670_1741005128.1138.png

클로드

2022631670_1741005190.9005.png

그록

2022631670_1741005249.8085.png

|

댓글 1개

이렇게 ai가알려주네요.

<!DOCTYPE html>
<html lang="ko">
<head>
  <meta charset="UTF-8">
  <title>HTML Preview in Popup</title>
  <!-- Prism CSS -->
  <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css" rel="stylesheet" />
  <style>
    .container {
      padding: 20px;
    }
    pre {
      width: 100%;
      height: 400px;
      border: 1px solid #ccc;
      margin: 0 0 10px 0;
    }
    button {
      padding: 10px 20px;
      font-size: 16px;
      cursor: pointer;
    }
  </style>
</head>
<body>
  <div class="container">
    <!-- 코드 입력 영역 -->
    <pre contenteditable="true" class="language-html"><code><div style="color: red;">Hello, World!</div>
<button onclick="alert('Popup Test!')">Click Me</button></code></pre>
    <!-- Preview 버튼 -->
    <button onclick="openPreview()">Preview</button>
  </div>

  <!-- Prism JS -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-html.min.js"></script>
  <!-- Preview 스크립트 -->
  <s cript>
    const codeElement = document.querySelector("pre code");

    // 초기 하이라이팅
    Prism.highlightAll();

    // 입력 시 실시간 하이라이팅
    codeElement.addEventListener("input", () => {
      Prism.highlightElement(codeElement);
    });

    // HTML 엔티티 디코딩 함수
    function decodeHtml(html) {
        console.log(html);
      const txt = document.createElement("textarea");
      txt.innerHTML = html;
      return txt.value;
    }

    // Preview 버튼 클릭 시 팝업 열기
    function openPreview() {
      const htmlContent = decodeHtml(codeElement.innerText); // 입력된 코드 가져오기
      const popup = window.open("", "HTMLPreview", "width=600,height=400"); // 팝업 창 열기
      if (popup) {
        popup.document.open();
        popup.document.write(`
          <!DOCTYPE html>
          <html lang="ko">
          <head>
            <meta charset="UTF-8">
            <title>Preview</title>
          </head>
          <body>
            ${htmlContent}
          </ body>
          </ html>
        `);
        popup.document.close();
      } else {
        alert("팝업 차단 설정을 확인해주세요!");
      }
    }
  </s cript>
</body>
</html>

댓글을 작성하시려면 로그인이 필요합니다.

자유게시판

203,246건
+
제목 글쓴이 날짜 조회
25-03-04 조회 1,031
25-03-04 조회 1,069
25-03-04 조회 1,117
25-03-04 조회 1,229
25-03-04 조회 1,032
25-03-04 조회 1,170
25-03-04 조회 1,241
25-03-04 조회 1,403
25-03-04 조회 1,308
25-03-04 조회 1,005
25-03-04 조회 1,106
25-03-04 조회 1,099
25-03-04 조회 1,191
25-03-04 조회 955
25-03-04 조회 993
25-03-04 조회 1,244
25-03-03 조회 1,115
25-03-03 조회 1,012
25-03-03 조회 986
25-03-03 조회 1,089