如何制作网页纠错系统

来源:百度知道 编辑:UC知道 时间:2024/09/21 04:03:21
就是用用鼠标选择出错的内容片断,然后同时按下“CTRL”与“ENTER”键,弹出一个报错页面,将用户反馈的错误提交到后台.
大概像这个网站的就行
http://www.haikou.gov.cn/Index.html

这是该网页源代码中的一部分javascript代码,自己看,要学会看源代码.

<script>
function getSelectedText() {

if (window.getSelection) {
return window.getSelection().toString();

} else if (document.getSelection) {
return document.getSelection();

} else if (document.selection) {//IE
return document.selection.createRange().text;
}
}

document.onkeydown = suberror;
function suberror(e)
{
var e = (typeof event != "undefined") ? window.event : e;
var s = getSelectedText();
if (e.ctrlKey && e.keyCode == 13) {
if (s != "")
{
if(s.length>2000){
alert("您选择的内容请不要超过2000个字符,请重新操作。");
return;
}else{
document.forms['suggest'].url.value = window.location.href;
document.forms['suggest'].errorstr.value = s;
//document.forms[&