2014-10-21 2 views
0

예를 들어, 나는 이런 식으로 뭔가를 좀하고 싶습니다 : document.write를document.write()에 큰 코드 조각을 얻는 방법이 있습니까?

<form> 
      <table> 

      <tr> 
       <td align="right">Subtotal:</td> 
       <td align="left"><form name = "e" id ="e"><input type="text" id="subtotal" /></td> 
      </tr> 

      <tr> 
       <td align="right">Sales Tax:</td> 
       <td align="left"><form name = "f" id = "f"><input type="text" id="tax" /></td> 
      </tr> 

      <tr> 
       <td align="right">Total:</td> 
       <td align="left"><form name = "g" id = "g"><input type="text" id="total" /></td> 
      </tr> 

      </table> 
    </form> 

에 내가 작동하지 않았다

document.write("paste whole code here"); 

같은 것을 시도했다.

+0

왜 그렇게하고 싶은거야? –

+2

document.write는 ** 페이지로드 후 ** 사용할 수 없습니다. 그렇지 않으면 전체 페이지를 덮어 씁니다. 언제'document.write()'를 호출할까요? – DividedByZero

+0

'document.write'에 원하는 문자열을 전달할 수 있습니다. 원하는만큼 오래있을 수 있습니다. 문제가 무엇인지는 명확하지 않습니다. –

답변

1

기록을 위해 나는 document.write의 사용을 권장하지 않습니다. 그러나 귀하의 질문에 대답하기 위해, 당신은 단순히 당신의 문자열에서 줄 바꿈을 탈출해야합니다

document.write('<form> \ 
 
       <table> \ 
 
       <tr> \ 
 
        <td align="right">Subtotal:</td> \ 
 
        <td align="left"><form name = "e" id ="e"><input type="text" id="subtotal" /></td> \ 
 
       </tr> \ 
 
       <tr> \ 
 
        <td align="right">Sales Tax:</td> \ 
 
        <td align="left"><form name = "f" id = "f"><input type="text" id="tax" /></td> \ 
 
       </tr> \ 
 
       <tr> \ 
 
        <td align="right">Total:</td> \ 
 
        <td align="left"><form name = "g" id = "g"><input type="text" id="total" /></td> \ 
 
       </tr> \ 
 
       </table> \ 
 
     </form>');

+0

감사합니다. 이 의견에 내 다른 질문을 연결하는 규칙에 어긋나지 않도록 귀하 또는 다른 사람들이 내 프로그램으로 무엇을하려고하는지 볼 수 있습니까? – user3577397

+0

참고로, 내가 보낸 링크를 확인하고 먼저 그렇게하려고합니다. – user3577397