JAVASCRIPT Tutorial

دليل موجز لجافاسكريبت سكرين

خطوات عملية لاستخدام screen object

  1. أنشئ متغيرًا للكائن screen:
    const screen = window.screen;
    
  2. احصل على دقة الشاشة:
    const resolution = `${screen.width}x${screen.height}`;
    
  3. احصل على خصائص الشاشة:
    const colorDepth = screen.colorDepth; // عمق اللون
    const pixelDepth = screen.pixelDepth; // عمق البكسل
    const aspectRatio = screen.aspectRatio; // نسبة العرض إلى الارتفاع
    
  4. تحقق من قدرات الشاشة:
    const touchEnabled = screen.touchEnabled; // هل يدعم لمس الشاشة
    const orientation = screen.orientation; // اتجاه الشاشة
    
  5. تعامل مع مدخلات اللمس:
    document.addEventListener('touchstart', (event) => {
      // تعامل مع مدخلات اللمس هنا
    });
    

مثال على جافاسكريبت لاستكشاف screen object

const screen = window.screen;

const output = `
  دقة الشاشة: ${screen.width}x${screen.height}
  عمق اللون: ${screen.colorDepth}
  يدعم لمس الشاشة: ${screen.touchEnabled}
`;

console.log(output);