javascript - setInterval is not working -


मान लीजिए मेरे पास फ़ंक्शन है:

  फ़ंक्शन chk () {alert ("Welcome" ); } Window.onload = chk (); सेट इन्टरवाल ("chk ();", 5000);  

लेकिन यह काम नहीं कर रहा है लेकिन जब मैं पृष्ठ को रीफ्रेश करता हूं तो यह मेरे लिए काम करता है मैं इसे कैसे ठीक कर सकता हूं?

यह केवल मेरे लिए ठीक काम करता है फंक्शन को कॉल करने और रिटर्न वैल्यू निर्दिष्ट करने के बजाय फ़ंक्शन संदर्भ के उपयोग पर ध्यान दें। SetInterval को स्ट्रिंग का उपयोग करने की आवश्यकता नहीं है - जो तर्क के eval को मजबूर करता है। आप फ़ंक्शन संदर्भ (या एक अनाम फ़ंक्शन) का उपयोग तर्क के रूप में भी कर सकते हैं।

  फ़ंक्शन chk () {चेतावनी ('चेकिंग'); } Window.onload = chk; setInterval (जच, 5000);  

Comments

Popular posts from this blog

Is there an open source WebSockets (JavaScript) XMPP library? -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -

mysql - Can mysql_pconnect be called multiple times in one php page? -