HTML में JavaScript एम्बेड करें - यहाँ बताया गया है कि कैसे
आप HTML में बाहरी जावास्क्रिप्ट को आसानी से एकीकृत कर सकते हैं। हम यहां आपको विभिन्न विकल्प दिखाते हैं।
जावास्क्रिप्ट को सीधे HTML पृष्ठों पर एम्बेड करें
स्क्रिप्ट को सिर में रखना सबसे अच्छा है ताकि आपका पेज और अन्य स्क्रिप्ट जल्दी से जल्दी लोड हो जाएं।
- HTML 5 में जावास्क्रिप्ट सम्मिलित करने के लिए, इन टैगों के बीच प्रविष्टि "XXXX" XXXX क्षेत्र में रखी गई है।
- यदि आप पुराने HTML संस्करण का उपयोग कर रहे हैं, तो स्क्रिप्ट इस तरह दिखाई देती है: XXXX।
- आपकी साइट पर आने वाले आगंतुकों के लिए जिन्होंने जावास्क्रिप्ट को सक्रिय नहीं किया है, आप जावास्क्रिप्ट के बजाय प्रदर्शित होने वाले पाठ को निर्दिष्ट करने के लिए "नोस्क्रिप्ट" का उपयोग कर सकते हैं।
- पूरा कमांड तब ऐसा दिखता है: XXXXPlease पेज खोलने के लिए जावास्क्रिप्ट सक्रिय करें
- यदि स्क्रिप्ट अन्य HTML पृष्ठों पर आवश्यक है, तो आपको इसे संबंधित व्यक्तिगत पृष्ठों में दर्ज करना होगा और प्रत्येक व्यक्तिगत पृष्ठ पर परिवर्तन करना होगा।
HTML पृष्ठों में जावास्क्रिप्ट को बाहरी फ़ाइल के रूप में एम्बेड करें
यदि आपके पास एक्सटेंशन .js वाली फ़ाइल में स्क्रिप्ट है, तो आप इसे निम्न तरीके से अपने पृष्ठ के शीर्ष लेख क्षेत्र में एम्बेड कर सकते हैं:
- HTML5 के लिए यह पर्याप्त है:
- पुराने HTML संस्करण के लिए, इस संस्करण का उपयोग करें:।
- एफ़टीपी प्रोग्राम का उपयोग करके .js फ़ाइल को अपने वेब सर्वर पर स्थानांतरित करें।
- एक जावास्क्रिप्ट फ़ाइल का महान लाभ यह है कि सभी पेज जावास्क्रिप्ट कार्यों तक पहुंच सकते हैं जैसे ही संबंधित वेबसाइट के प्रमुख में लिंक डाला गया है।
- परिवर्तन केवल .js फ़ाइल में आवश्यक हैं और अब हर एक पृष्ठ पर नहीं हैं।
अगले व्यावहारिक टिप में हम बताएंगे कि आप जावास्क्रिप्ट को वर्डप्रेस में कैसे एकीकृत कर सकते हैं।