לוגו אתר Fresh          
 
 
  אפשרות תפריט  ראשי     אפשרות תפריט  צ'אט     אפשרות תפריט  מבזקים     אפשרות תפריט  צור קשר     חץ שמאלה ‎print ‎"Hello World!"; if‎ ‎not rules.‎know ‎then rules.‎read(); חץ ימינה  

לך אחורה   לובי הפורומים > מחשבים > תכנות ובניית אתרים
שמור לעצמך קישור לדף זה באתרי שמירת קישורים חברתיים
תגובה
 
כלי אשכול חפש באשכול זה



  #1  
ישן 12-06-2007, 16:24
צלמית המשתמש של tnadav1
  משתמש זכר tnadav1 tnadav1 אינו מחובר  
 
חבר מתאריך: 02.10.05
הודעות: 2,355
שלח הודעה דרך MSN אל tnadav1
בעיה ב- JS, אירועים

כבר שלחתי את הבעיה הזאת בפורום, אבל אף אחד לא ענה לי...
עכשיו, יש לי הזדמנות שוב להיות בפורום אז אני שולח את הבעיה הזאת שוב בתקווה שיענו לי.

אני מכין מחלקה ליצירת חלון צף, הבעיה היא כאשר אני רוצה לקבל את המיקום של העכבר, הנה קטע הקוד הרלוונטי:
קוד PHP:
 this.updatePos = function(e)
{
    if(
document.all)
        
event;
    
//-------------------------
    
this.windowObj.style.left  this.startClient['x'] + e.clientX this.findX  'px';
    
this.windowObj.style.top   this.startClient['y'] + e.clientY this.findY  'px';
}
this.stopMove = function()
{
    
this.onmousemove null;
    
this.onmouseup   null;
}
this.initMove = function(e)
{
    if(
document.all)
        
event;
            
    
this.startClient['x']          = e.clientX;
    
this.startClient['y']          = e.clientY;
    
obj this;
    
this.windowTopObj.onmousemove  = function () {obj.updatePos()};
    
this.windowTopObj.onmouseup    this.stopMove;
}    
// Making evant
obj this;
this.windowTopObj.onmousedown      = function () {obj.initMove()};} 

והבעיה היא בשורה הזו:
קוד PHP:
 this.startClient['x']          = e.clientX

ב- Error Console של פיירפוקס כתוב:
e has no properties

אני לא מבין כל-כך באירועים.. חיפשתי על זה ב- w3schools ולא מצאתי את מה שאני מחפש..

איך זה אמור לעבוד כל הקטע הזה עם e?

בבקשה תענו מהר למה עוד מעט אני לא יוכל לגלוש בפרש (אני חושב)
_____________________________________


תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #3  
ישן 12-06-2007, 22:52
צלמית המשתמש של tnadav1
  משתמש זכר tnadav1 tnadav1 אינו מחובר  
 
חבר מתאריך: 02.10.05
הודעות: 2,355
שלח הודעה דרך MSN אל tnadav1
בתגובה להודעה מספר 2 שנכתבה על ידי ישראל K שמתחילה ב "למה לא תוכל לגלוש בפרש? (אנסה..."

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

עוד מעט כנראה יהיה לי עוד אישפוז.. ואז אני לא ממש יוכל לתפקד לכמה ימים.. ועד אז האשכול הזה יהיה בדף 3...

בכל מקרה, הפיתרון של מקסים עובד, רק שעכשיו יש הרבה הרבה הודעות שגיאה (מתי זה יעבוד? :S)
זה מה שכתוב (בערך) ב- Error Console של פיירפוקס:
Error in parsing value for property 'left'. Declaration dropped.
Error in parsing value for property 'top'. Declaration dropped.
רק הרבה הרבה פעמים...
יש מושג למה זה קורה?..
הנה הקוד של המחלקה המלא:
קוד PHP:
 var 0;
var 
floatWindow = function(weightheightwindowTitle)
{
    
//reset all values
    
i++;
    
this.weight       =  weight;
    
this.height       =  height;
    
this.windowId     "window_"+i;
    
this.windowTopId  "window_top_"+i;
    
this.windowTitle  =  windowTitle;
    
this.startClient  =  new Array();
    
//Making a design of window
    
var windowContent "<div class='window_top' id='"+this.windowTopId+"'>"+windowTitle;
        
//coming soon...
            //<img src='images/top_left.gif' align='left'>
            //<img src='images/top_center.gif' class='topCenterImage'>
            //<<div class='top_buttons'>
                //<img class='minimizeButton' src='images/minimize.gif'>
                //<img class='closeButton' src='images/close.gif'>
        
                //<img src='images/top_right.gif'>
            //</div>
        
windowContent += "</div>";
        
windowContent += "<div class='windowMiddle'>";
            
windowContent += "<div class='windowContent'>";
                
//Starting window content...
                
windowContent += "Testing..Testing..123";
                
//End of window content...
            
windowContent += "</div>";
        
windowContent += "</div>";
        
windowContent += "<div class='window_bottom'>";
            
//<img class="resizeImage" src="images/bottom_right.gif">
        
windowContent += "</div>";
    
//Creating the element...
    
var window        document.createElement("div");
    
window.id         this.windowId;
    
window.className  'window';
    
window.innerHTML  windowContent;
    
document.body.appendChild(window);
    
this.windowObj    document.getElementById(this.windowId);
    
this.windowTopObj document.getElementById(this.windowTopId);
    
//end of creating element...
    //other functions...
    
this.findX = function()
      {
        
obj this.windowObj;
        var 
curleft 0;
        if(
obj.offsetParent)
            while(
1
            {
                  
curleft += obj.offsetLeft;
                      if(!
obj.offsetParent)
                        break;
                  
obj obj.offsetParent;
            }
        else if(
obj.x)
            
curleft += obj.x;
        
        return 
curleft;
    }    
    
this.findY = function()
      {
        
obj this.windowObj;
        var 
curtop 0;
        if(
obj.offsetParent)
            while(
1)
            {
                  
curtop += obj.offsetTop;
                  if(!
obj.offsetParent)
                    break;
                  
obj obj.offsetParent;
            }
        else if(
obj.y)
            
curtop += obj.y;
        return 
curtop;
      }
    
this.updatePos = function(e)
    {
        if(
document.all)
            
event;
        
//-------------------------
        
this.windowObj.style.left this.startClient['x'] + e.clientX this.findX  'px';
        
this.windowObj.style.top  this.startClient['y'] + e.clientY this.findY  'px';
    }
    
this.stopMove = function()
    {
        
this.onmousemove null;
        
this.onmouseup   null;
    }
    
this.initMove = function(e)
    {
        if(
document.all)
            
event;
        
        
this.startClient['x']          = e.clientX;
        
this.startClient['y']          = e.clientY;
        
        
obj this;
        
this.windowTopObj.onmousemove  = function () {obj.updatePos(e)};
        
this.windowTopObj.onmouseup    this.stopMove;
    }
    
// Making evant
    
obj this;
    
this.windowTopObj.onmousedown      = function (e) {obj.initMove(e)};

_____________________________________



נערך לאחרונה ע"י tnadav1 בתאריך 12-06-2007 בשעה 23:02.
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #4  
ישן 12-06-2007, 23:02
  ישראל K ישראל K אינו מחובר  
 
חבר מתאריך: 25.08.03
הודעות: 9,114
בתגובה להודעה מספר 3 שנכתבה על ידי tnadav1 שמתחילה ב "כמו שכתבתי פה בעבר, (כנראה לא..."

שאלתי דווקא בגלל שראיתי שכתבת שאושפזת בחיפה, אני מבין שאתה חוזר לרמב"ם.
שתהיה לך רפואה שלימה.

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

עריכה:
לגבי ההודעות שגיאה שציינת, תוודא שאתה לא נותן למאפייני המיקום של css ערכים מספריים אלא ערך הכולל מספר+יחידת-המידה. לדוגמה:
קוד:
element.style.left = '10px'

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

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

נערך לאחרונה ע"י ישראל K בתאריך 12-06-2007 בשעה 23:21.
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #9  
ישן 13-06-2007, 14:31
צלמית המשתמש של tnadav1
  משתמש זכר tnadav1 tnadav1 אינו מחובר  
 
חבר מתאריך: 02.10.05
הודעות: 2,355
שלח הודעה דרך MSN אל tnadav1
בתגובה להודעה מספר 6 שנכתבה על ידי maxim k שמתחילה ב "כפי שהבטחתי :)"

כאשר לא עושים כלום באמת אין שגיאות, אבל אם תנסה להזיז את החלון תראה שיש הרבה ב- Error
console

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

בכל מקרה.. עכשיו זה פועל איכשהו.. אבל פועל מוזר..
אני מעלה את הקובץ בשביל להראות מה קורה.. בכל מקרה, הנה המחלקה המלאה כרגע:
קוד PHP:
 var 0;
var 
floatWindow = function(weightheightwindowTitle)
{
    
//reset all values
    
i++;
    
this.weight       =  weight;
    
this.height       =  height;
    
this.windowId     "window_"+i;
    
this.windowTopId  "window_top_"+i;
    
this.windowTitle  =  windowTitle;
    
this.startClient  =  new Array();
    
//Making a design of window
    
var windowContent "<div class='window_top' id='"+this.windowTopId+"'>"+windowTitle;
        
//coming soon...
            //<img src='images/top_left.gif' align='left'>
            //<img src='images/top_center.gif' class='topCenterImage'>
            //<<div class='top_buttons'>
                //<img class='minimizeButton' src='images/minimize.gif'>
                //<img class='closeButton' src='images/close.gif'>
        
                //<img src='images/top_right.gif'>
            //</div>
        
windowContent += "</div>";
        
windowContent += "<div class='windowMiddle'>";
            
windowContent += "<div class='windowContent'>";
                
//Starting window content...
                
windowContent += "Testing..Testing..123";
                
//End of window content...
            
windowContent += "</div>";
        
windowContent += "</div>";
        
windowContent += "<div class='window_bottom'>";
            
//<img class="resizeImage" src="images/bottom_right.gif">
        
windowContent += "</div>";
    
//Creating the element...
    
var newWindow        document.createElement("div");
    
newWindow.id         this.windowId;
    
newWindow.className  'window';
    
newWindow.innerHTML  windowContent;
    
document.body.appendChild(newWindow);
    
this.windowObj    document.getElementById(this.windowId);
    
this.windowTopObj document.getElementById(this.windowTopId);
    
//end of creating element...
    //other functions...
    
this.findX = function()
      {
        
obj this.windowObj;
        var 
curleft 0;
        if(
obj.offsetParent)
            while(
1
            {
                  
curleft += obj.offsetLeft;
                      if(!
obj.offsetParent)
                        break;
                  
obj obj.offsetParent;
            }
        else if(
obj.x)
            
curleft += obj.x;
        
        return 
curleft;
    }    
    
this.findY = function()
      {
        
obj this.windowObj;
        var 
curtop 0;
        if(
obj.offsetParent)
            while(
1)
            {
                  
curtop += obj.offsetTop;
                  if(!
obj.offsetParent)
                    break;
                  
obj obj.offsetParent;
            }
        else if(
obj.y)
            
curtop += obj.y;
        return 
curtop;
      }
    
this.updatePos = function(e)
    {
        if(
document.all)
            
event;
        
//-------------------------
        
this.windowObj.style.left = (this.startClient['x'] + e.clientX this.findX())  + 'px';
        
this.windowObj.style.top  = (this.startClient['y'] + e.clientY this.findY())  + 'px';
    }
    
this.stopMove = function()
    {
        
this.onmousemove null;
        
this.onmouseup   null;
    }
    
this.initMove = function(e)
    {
        if(
document.all)
            
event;
        
        
this.startClient['x']          = e.clientX;
        
this.startClient['y']          = e.clientY;
        
        
obj this;
        
this.windowTopObj.onmousemove  = function (e) {obj.updatePos(e)};
        
//this.windowTopObj.onmouseup    = this.stopMove;
    
}
    
// Making evant
    
obj this;
    
this.windowTopObj.onmousedown      = function (e) {obj.initMove(e)};


והנה הקובץ
https://2007-uploaded.fresh.co.il/2...3/19192460.html
_____________________________________



נערך לאחרונה ע"י tnadav1 בתאריך 13-06-2007 בשעה 14:44.
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #11  
ישן 13-06-2007, 19:19
  DCD DCD אינו מחובר  
 
חבר מתאריך: 17.05.05
הודעות: 7,321
בתגובה להודעה מספר 9 שנכתבה על ידי tnadav1 שמתחילה ב "כאשר לא עושים כלום באמת אין..."

וואי רק עכשיו ידוע לי שאתה במצב הזה, שתהיה לך רפואה שלמה!

ואני חושב שהבעיה עכשיו היא שלא הכרזת על המשתנה obj כ-var (משתנה גלובאלי).

כי כשקראת לו בתוך הפונקציה בשורות 180 ו-185, הדפדפן לא הבין מי זה המשתנה הזה.

לכן, בקיצור, הקוד שלך (התמקדות על החלק הלא טוב):

קוד:
obj = this; this.windowTopObj.onmousemove = function (e) {obj.updatePos(e)}; //this.windowTopObj.onmouseup = this.stopMove; } // Making evant obj = this; this.windowTopObj.onmousedown = function (e) {obj.initMove(e)};


הקוד התקין:

קוד:
var obj = this; this.windowTopObj.onmousemove = function (e) {obj.updatePos(e)}; //this.windowTopObj.onmouseup = this.stopMove; } // Making evant var obj = this; this.windowTopObj.onmousedown = function (e) {obj.initMove(e)};


שים לב שרק הוספתי את המילה var לפני המשתנה obj ב-2 המקומות.
מקווה שעכשיו זה יעבוד, בהצלחה!

עריכה:

טעות, זה הקוד התקין יותר (אותו קטע הקוד הנ"ל עם שינוי קטן):

קוד:
var obj = this; this.windowTopObj.onmousemove = function (e) {obj.updatePos(e)}; //this.windowTopObj.onmouseup = this.stopMove; } // Making evant var newObj = this; this.windowTopObj.onmousedown = function (e) {newObj.initMove(e)};


שים לב שרק שיניתי את שם המשתנה obj שהגדרת אותו בפעם השניה.
אסור לך לקרוא לו פעמיים במקרה הזה, כי אח"כ המשתנה obj (אם הוא גלובאלי) הוא גם משומש בפונקציה initMove של המחלקה, ובגלל שהוא מוגדר שוב ומוגדר שונה אז יכולות להיות בעיות אם מנסים להזיז בפעם השניה...

אבל בכל זאת, למרות שאין שגיאות JS, הקוד לא עובד כל כך טוב, צריך לשפר אותו.

נערך לאחרונה ע"י DCD בתאריך 13-06-2007 בשעה 19:25.
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

כלי אשכול חפש באשכול זה
חפש באשכול זה:

חיפוש מתקדם
מצבי תצוגה דרג אשכול זה
דרג אשכול זה:

מזער את תיבת המידע אפשרויות משלוח הודעות
אתה לא יכול לפתוח אשכולות חדשים
אתה לא יכול להגיב לאשכולות
אתה לא יכול לצרף קבצים
אתה לא יכול לערוך את ההודעות שלך

קוד vB פעיל
קוד [IMG] פעיל
קוד HTML כבוי
מעבר לפורום



כל הזמנים המוצגים בדף זה הם לפי איזור זמן GMT +2. השעה כעת היא 06:14

הדף נוצר ב 0.26 שניות עם 10 שאילתות

הפורום מבוסס על vBulletin, גירסא 3.0.6
כל הזכויות לתוכנת הפורומים שמורות © 2024 - 2000 לחברת Jelsoft Enterprises.
כל הזכויות שמורות ל Fresh.co.il ©

צור קשר | תקנון האתר