-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkdown.html
56 lines (52 loc) · 1.61 KB
/
markdown.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!-- <!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
</head>
<script src="public/js/marked.min.js"></script>
<div id="content"></div>
<script>
document.getElementById('content').innerHTML = marked.parse('# 这是一个markdown测试文件');
</script>
</html>
-->
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>md文档内容转成html显示</title>
</head>
<body>
<!-- <div id="content" style="width: 500px;height: 500px;overflow: auto"></div> -->
<div id="content" style="height: 500px;overflow: auto"></div>
<div style="margin-top: 30px">
<form name="form" action="" method="post">
<select name="q">
<!-- <option value="md/gs.md">公式</option> -->
<option value="test.md">Markdown文档</option>
</select>
<input type="button" value="显示" onclick="showMarkdown()">
</form>
</div>
<script type="text/javascript" src='public/js/marked.min.js'></script>
<script type="text/javascript">
function showMarkdown() {
var f = form;
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject('Microsoft.XMLHttp');
}
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById('content').innerHTML = marked(xmlhttp.responseText);
}
}
// 向服务器发送请求
xmlhttp.open('GET', f.q.value, true);
xmlhttp.send();
}
</script>
</body>
</html>