最近在学html5跨文档通信时,浏览器报错:doucument is not defined?求教高手们,这是怎么回事?
var defaultTitle = "Portal [new message]";
//
var notificationTimer = null;
var trustedOrigin = "http://localhost:8080";
// 消息处理
function messageHandler(e) {
if (e.origin == trustedOrigin) {
notify(e.data);
} else {
}
}
// 处理闪烁
function notify(message) {
stopBlinking();
blinkTitle(message, defaultTitle);
}
// 停止闪烁
function stopBlinking() {
if (notificationTimer != null) {
clearTimeout(notificationTimer);
}
document.title = defaultTitle;
}
// 闪烁的信息
function blinkTitle(m1, m2) {
// ReferenceError: doucument is not defined
doucument.title = m1;
notificationTimer = setTimeout(blinkTitle, 1000, m2, m1);
}
// 信息发送——向iframe
function sendStatus() {
var statusText = document.getElementById("statusText").value;
sendString(statusText);
}
// 消息发送——向iframe
function sendString(s) {
document.getElementById("widget").contentWindow.postMessage(s, trustedOrigin);
}
function loadDemo() {
document.getElementById("sendButton").addEventListener("click", sendStatus, true);
document.getElementById("stopButton").addEventListener("click", stopBlinking, true);
sendStatus();
}
window.addEventListener("load", loadDemo, true);
window.addEventListener("message", messageHandler, true);