הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   "there is no attribute "onload (https://hosts.co.il/forums/showthread.php?t=55595)

rsl 25-10-07 02:29

"there is no attribute "onload
 
אני משתמש ב- onload כדי לזמן פונקציה מסויימת מקובץ javascript

כשאני בודק את הדף ב w3c validator אני מקבל רק error אחד.

קוד:

there is no attribute "onload".
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.

בניתי את הדף כ: XHTML 1.0 Transitional
לא מצאתי דרך לפתור את זה, אני צריך את עזרתכם :/
יש אולי איזה דרך לשלב את זה בדרך אחרת ולא עם onload?

meshuga 25-10-07 02:53

ציטוט:

נכתב במקור על ידי rsl (פרסם 571111)
אני משתמש ב- onload כדי לזמן פונקציה מסויימת מקובץ javascript

כשאני בודק את הדף ב w3c validator אני מקבל רק error אחד.

קוד:

there is no attribute "onload".
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.

בניתי את הדף כ: XHTML 1.0 Transitional
לא מצאתי דרך לפתור את זה, אני צריך את עזרתכם :/
יש אולי איזה דרך לשלב את זה בדרך אחרת ולא עם onload?

על איזה תג שמת את זה?
אם זה על body, אז אין לי מושג..
אם זה לא...אז נראה לי שמותר לשים את זה רק על body

rsl 25-10-07 13:24

ציטוט:

נכתב במקור על ידי meshuga (פרסם 571114)
על איזה תג שמת את זה?
אם זה על body, אז אין לי מושג..
אם זה לא...אז נראה לי שמותר לשים את זה רק על body

שמתי את זה על img ... כנראה שזה לא מותר
אבל איך אני יכול לפתור את זה שזה עדיין יעשה את הפעולה שאני רוצה ושזה יעבור את הבדיקה?
אפשר אולי איכשהו לשלב כזה דבר ב-css או משהו כזה?

בניה 25-10-07 13:39

למה ה onload מחכה?
שהתמונה תטען?

somebody 25-10-07 15:53

אם זו פונקציה שהשימוש בה הוא רק בonload יש דרך לעשות את זה ב JS.
אתה כותב:

PHP קוד:

onload=function()
{
הפונקציה


וזה כמובן נימצא בין תגי JS.

rsl 26-10-07 18:53

ציטוט:

נכתב במקור על ידי בניה (פרסם 571215)
למה ה onload מחכה?
שהתמונה תטען?

כן, זה סקריפט שבמידה והתמונה חורגת מהגדלים שאני קובע זה מקטין אותה ורק אם לוחצים עליה קליק בעכבר היא נפתחת לגודל הרגיל שלה, ואם לוחצים שוב זה מקטין אותה שוב.

ציטוט:

נכתב במקור על ידי somebody (פרסם 571257)
אם זו פונקציה שהשימוש בה הוא רק בonload יש דרך לעשות את זה ב JS.
אתה כותב:

PHP קוד:

onload=function()
{
&
#1492;פונקציה


וזה כמובן נימצא בין תגי JS.

נו ובמידה וזה בין תגי javascript.. איך זה יכול להשפיע על תמונה ספציפית? ממש לא הבנתי את הרעיון :/

O-B 26-10-07 19:45

עם ID..

rsl 26-10-07 20:25

ניסיתי ולא הלך לי.

ניסיתי לעשות את זה ככה:
קוד:

<script language='JavaScript' type='text/javascript' src='script.js'>
<!--
onload=function sizecap() {
imageSizeCap(this, 800, 800);
}
//-->
</script>

זה ב-HEAD

וב-img עשיתי משהו כמו זה:
קוד:

<img src="pic.jpg" id="sizecap" />
וזה לא עבד לי ... פשוט לא טען את התמונה.

חיים 26-10-07 20:53

HTML קוד:

<script language='JavaScript' type='text/javascript' src='script.js'>
<!--
document.getElementById('sizecap').onload=function(){
imageSizeCap(this, 800, 800);
}
//-->

</script>


rsl 26-10-07 21:06

תודה רבה על הניסיון, אבל לצערי גם זה לא פועל.

בניה 27-10-07 09:03

לתמונה לא קיים כזה אירוע onLoad

אפשר לעשות את זה בצד שרת.(לבדוק את המימדים של התמונה עם getimagesize)

או לעשות לולאה שתעבור על כל התמונות במסמך בJS אבל אני לא בטוח שאם התמונה לא תטען אז תקבל את המידע על האורך והרוחב.

חיים 27-10-07 10:48

ציטוט:

נכתב במקור על ידי בניה (פרסם 571822)
לתמונה לא קיים כזה אירוע onLoad

בניה אתה לא צודק בכלל... בדקתי באתרים מכל מיני וגיליתי שזה בהחלט מותר...
http://msdn2.microsoft.com/en-us/library/ms536942.aspx
נסה ככה:
HTML קוד:

<script language="JavaScript" type="text/javascript" src="script.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('sizecap').onload=function(){
imageSizeCap(document.getElementById('sizecap'), 800, 800);
}
//-->

</script>


Daniel 27-10-07 11:05

ציטוט:

נכתב במקור על ידי חיים (פרסם 571841)
בניה אתה לא צודק בכלל... בדקתי באתרים מכל מיני וגיליתי שזה בהחלט מותר...
http://msdn2.microsoft.com/en-us/library/ms536942.aspx
נסה ככה:
HTML קוד:

<script language="JavaScript" type="text/javascript" src="script.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('sizecap').onload=function(){
imageSizeCap(document.getElementById('sizecap'), 800, 800);
}
//-->

</script>


מייקרוסופט זה בן המקומות הפחות אמינים למידע שיתאים לדפדפן כלשהו חוץ מאקספלורר.

בניה 27-10-07 17:51

סליחה, בדקתי ובIE ו FF וזה עובד, פשוט זה רק לא תקני כנראה(לפחות לא בHTML 4)
תנסה את זה:
קוד:

<script language='JavaScript' type='text/javascript' src='script.js'></script>
<script type="text/javascript">
<!--
document.getElementById('sizecap').onload = function(){
        imageSizeCap(document.getElementById('sizecap'), 800, 800);
}
//-->
</script>


rsl 28-10-07 01:01

עדיין לא עוזר... יש לך אולי עוד הצעות ?:|

somebody 28-10-07 01:28

אני הייתי עושה בכלל משהו אחר..
טוען את התמונה בJS, את הכל עושה ב JS, ואז בסוף הייתי עושה שהאלנט של ה IMG שהID שלו הוא X, ה SRC שלו יהיה שווה לSRC של המשתנה, בו השתמש בJS.
ואת זה עושים בעזרת הגדרת משתנה כ new Image, ואז פעולות רגילות כמו שאתה רגיל, רק ב JS.
ואז אין לך שום בעיה של Onload בHTML עצמו.

RS324 28-10-07 06:20

נסה את זה...
PHP קוד:

<script type="text/javascript">

var 
capimage = new image(800,800);
capimage.src ='./images/myimage.jpg';

document['capimage'].srccapimage
</script>
 

תשחק עם זה קצת... אני מאמין שזה יעזור לך


כל הזמנים הם GMT +2. הזמן כעת הוא 10:54.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ