자바 스크립트를 사용하여 웹 페이지에서 텍스트 파일이나 HTML 파일을 열고 텍스트 파일의 내용이나 HTML 코드를 텍스트 영역으로로드하는 방법 제발 해달라고 javscript를 사용하여 불가능한 말해,하지만 가능하지만 코드와 내 집에 일주일 오지 않을 알아. 예제 코드는 크게 감사하겠습니다. (난 이미이 질문을했지만 모두가 질문의 다른 부분에 집중하는 것 같았다.)HTML 파일의 텍스트 파일이나 HTML 코드의 내용을 먼저 탐색하여 텍스트 영역에로드하는 방법은 무엇입니까?
<html>
<body>
<form name="abc">
<textarea name="text">loaded text here</textarea>
<input type="button" onClick=""> open file
</form>
</body>
</html>
내가, 포럼이 발견 이름을 기억 해달라고,이 작업 코드 만 텍스트 파일을로드 할 수 있습니다 .... 이제 질문은 htmlcodes를 html 파일에서 가져올 수있는 방법입니다. 유 시간 근래 경우
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var ForReading = 1, ForWriting = 2, ForAppending = 8;
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
function loadFile(btn, obj, div, fld) {
objFile = objFSO.GetFile(obj.value);
objStream = objFile.OpenAsTextStream(ForReading);
fld.value = objStream.ReadAll();
objStream.Close();
objStream= null;
fileSpecs(div, btn);
objFile = null;
return true;
}
</script>
</head>
<body>
<form name="myForm" onsubmit="return false;">
<textarea rows="25" name="fileArea" cols="70"
onkeypress="return checkText(this, btnSave);"></textarea> </td>
<input type="file" name="fileName" size="50"
onchange="return checkFile(this, document.getElementById('fileSpec'), btnLoad, btnSave, fileArea);">
<input type="button" name="btnLoad" value="Load"
onclick="return loadFile(this, fileName, document.getElementById('fileSpec'), fileArea);">
</form>
</body>
</html>
이 코더가 작동 할 수 있지만 NT 나를 위해 노력하고 주장하는 또 하나,이 코드를 실행하시기 바랍니다 ... 여기에 전체 코드를 제공하시기 바랍니다 작동하는지. (코라에 의해 코딩)
<html>
<head>
<script type="text/javascript">
function init(){
var extText = window.frames.messageTxt.document.body.lastChild.lastChild.data;
extText = extText.replace(/[\r\n]/g," ");
document.forms[0].nMessage.value = extText;
}
window.onload=init;
</script>
</head>
<body>
<iframe name='messageTxt' src='txtData.txt' style='display:none'></iframe>
<form>
<textarea name='nMessage'></textarea>
<input type="button" value="click" onClick="init()">
</form>
</body>
</html>
나는이 작업을 수행 할 수있는 ... 나는 htmlcode가 텍스트 영역에 외부 HTML 파일을 형성로드 할 수 있습니다 자바 스크립트를했다 생각하지 않습니다. 그러나 나는 그 파일을 잃어 버렸습니다. 슬픈 사람은 js 함수 (또는 액티브 x)를 만들 수있는 스크립팅 능력을 가지고 있지 않습니다.
그게 불가능합니다 ... 농담 .. :) – Reigel
잘못된 스크립트를 가지고 있습니다. onclick = "", 인용 부호를 이스케이프 처리하거나 따옴표를 제거해야합니다 ... 초 : " ajax_json_echo "루트 폴더 아래에? 서버 쪽 페이지 여야합니다 ... 크로스 브라우저에 대한 요구 사항이 없으면이 링크는 IE에서만 작동합니다. http://msdn.microsoft.com/en-us/library/ms531417 (v = VS.85) .aspx – Ayyash
고맙습니다. IE에서만 작동해야합니다 (다른 브라우저는 신경 쓰지 않아야합니다.) 그리고 havaj ajax _json_echo 파일을 ..... ..... 그래서 gona 사이트를 지금 확인하고 있습니다. – subanki