테스트를 위해 코드 블록을 사용하는 경우 <xsl:key name="Name" match="/NewSet/ps1/Name/text()" use="." />
으로 시작하는 원본 HTML을 첫 번째 상자에 쓰고 세 번째 상자에서 결과를 가져옵니다. "HTML 모드의 IFRAME "like <xsl:key name="Name" match="/NewSet/ps1/Name/text()" use="." ></xsl:key>
HTML에서 "/"삭제 금지
결과는 /
입니다.이 문제를 방지하려면 어떻게해야합니까?
나는 이것이 브라우저의 텍스트 엔진에 관한 것이라고 생각하십니까? 그렇지 않니?
<html>
<head>
<title>Editable IFRAME test</title>
</head>
<body onload="SetEditable()">
<b>Set your original HTML content here:</b><br />
<textarea id="htmlArea" style="width: 783px; height: 189px"></textarea>
<br />
<input type="button" onclick="CreateHtml();return false;" value="Set Content in the IFRAME">
<br />
<b>Editable IFRAME element:</b>
<br />
<div style="width: 800px; height: 600px; border: 1px solid red;">
<iframe style="padding-bottom: 0px; margin: 0px; padding-left: 0px; width: 100%;
padding-right: 0px; height: 100%; padding-top: 0px" frameborder="0" src="javascript:void(0)"
id="editor"></iframe>
</div>
<input type="button" onclick="ShowIFRAMEHTML();return false;" value="Show IFRAME HTML">
<br />
<b>HTML Mode of the IFRAME:</b>
<br />
<textarea id="htmlMode" style="width: 783px; height: 313px"></textarea>
<script type="text/javascript">
var editor1 = document.getElementById("editor"); //reference to the IFRAME element
var htmlArea1 = document.getElementById("htmlArea"); //reference to the HTML area in which we put the content
var htmlMode = document.getElementById("htmlMode"); //reference to the HTML area that displays the IFRAME content
var oDocument = editor1.contentWindow.document;
var sMarkup = "<html><head><title>New Document</title></head>" +
"<body contenteditable=true style='overflow:scroll;margin:0px;padding:0px;height:100%'>" +
" </body></html>";
function SetEditable() {
oDocument.open();
oDocument.write(sMarkup);
oDocument.close();
oDocument["designMode"] = "on";
oDocument.execCommand("2D-Position", false, true);
}
function CreateHtml() {
oDocument.body.innerHTML = htmlArea1.value;
htmlMode.value = oDocument.body.innerHTML;
}
function ShowIFRAMEHTML() {
alert(oDocument.body.innerHTML);
}
</script>
</body>
</html>
'innerHTML' 대신'.innerText' 또는'.textContent'를 사용 해보세요. (예 :'htmlMode.value = (oDocument.body.innerText || oDocument.body.textContent)') –
당신은 맞습니다 @ 페드로 에스트라다, 고마워. –