最近在學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);
doucument
.title = m1;
你拼錯了吧, 應該是 document