onerror 點改先符合 w3c ?

編寫、設計網頁與程式。

版主: hamu278, 銘仔

版面規則
  • 本版面亦可以討論網頁寄存公司

onerror 點改先符合 w3c ?

文章skyhks » 2008-11-01, 15:56

Line 136, Column 113: there is no attribute "onerror".

…stomavatars/000/00/00/1.gif" onerror="this.onerror=null;this.src='images/avat



You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash.

改淨 1個 error :oops:
圖檔
頭像
skyhks
地球會員
 
文章: 1337
註冊時間: 2006-10-01, 17:08
來自: 香港

Re: onerror 點改先符合 w3c ?

文章Puff » 2008-11-01, 16:11

代碼: 選擇全部
<script type="text/javascript">
// Use JQuery...
$('img').error(function() {
$(this).attr('src', './noavatar.gif');
return false;
});


代碼: 選擇全部
<script type="text/javascript">
// without JQuery...
function noavatar(event) {
target = event.target || window.event.target;
target.src = './noavatar.gif';
return false;
}
for(var i = 0, g = document.getElementsByTagName('img'); i < g.length; i++ ) {
if( document.addEventListener ) document.addEventListener(g[i], 'error', noavatar);
if( document.attachEvent ) document.attachEvent(g[i], 'onerror', noavatar);
}


:oops:
最後由 Puff 於 2008-11-01, 16:33 編輯,總共編輯了 2 次。
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: onerror 點改先符合 w3c ?

文章hamu278 » 2008-11-01, 16:15

viewtopic.php?f=100&t=4542
我既回覆問過 :P
圖檔
頭像
hamu278
金星會員
 
文章: 4482
註冊時間: 2006-06-04, 08:49
來自: 香港

Re: onerror 點改先符合 w3c ?

文章Puff » 2008-11-01, 16:16

hamu278 寫:http://bbs.i-circle.net/viewtopic.php?f=100&t=4542
我既回覆問過 :P

你想叫人每個 <img> element 都寫一次? :lol:
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: onerror 點改先符合 w3c ?

文章skyhks » 2008-11-01, 16:23

唔知點寫-.-
正係知刪左 onerror 就 Valid
圖檔
頭像
skyhks
地球會員
 
文章: 1337
註冊時間: 2006-10-01, 17:08
來自: 香港

Re: onerror 點改先符合 w3c ?

文章Puff » 2008-11-01, 16:33

skyhks 寫:唔知點寫-.-
正係知刪左 onerror 就 Valid

咪講左 :lol:
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: onerror 點改先符合 w3c ?

文章skyhks » 2008-11-01, 18:54

http://www.w3schools.com/jsref/jsref_onError.asp
佢話要 onerror="JS CODE", img 有冇得 js 化?
圖檔
頭像
skyhks
地球會員
 
文章: 1337
註冊時間: 2006-10-01, 17:08
來自: 香港

Re: onerror 點改先符合 w3c ?

文章銘仔 » 2008-11-01, 19:21

skyhks 寫:http://www.w3schools.com/jsref/jsref_onError.asp
佢話要 onerror="JS CODE", img 有冇得 js 化?

我之前問過onload,onerror都一樣xDDDD
頭像
銘仔
金星會員
 
文章: 3017
註冊時間: 2007-04-05, 20:36

Re: onerror 點改先符合 w3c ?

文章hamu278 » 2008-11-01, 19:24

銘仔 寫:
skyhks 寫:http://www.w3schools.com/jsref/jsref_onError.asp
佢話要 onerror="JS CODE", img 有冇得 js 化?

我之前問過onload,onerror都一樣xDDDD


viewtopic.php?f=100&t=7239&p=60549
8-)
圖檔
頭像
hamu278
金星會員
 
文章: 4482
註冊時間: 2006-06-04, 08:49
來自: 香港


回到 [B1] 網頁製作、程式編寫與介面設計



誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 9 位訪客

cron