Navigator Object

Navigator គឺ​ជា​វត្ថុ​មួយ​​នៅ​ក្នុង​ចំណោម​វត្ថុ​ជាច្រើន​ទៀត ដែល​មាន​នៅ​ក្នុង​BOM (browser object model) ។ នៅ​ក្នុង​វត្ថុ​នោះ មាន​សម្បត្តិ​មួយ​ចំនួន​ ដែល​អាច​ត្រូវ​យក​មក​ប្រើ​សំរាប​ពិនិត្យ​មើល​លក្ខណៈ​បច្ចេកទេស​របស់​ browser មាន​ដូច​ជា​សម្បត្តិឈ្មោះ cookieEnabled ជាដើម ដែល​អាច​អោយ​យើង​ដឹង​ថា​តើ browser អាច​អនុញ្ញាត​អោយ​យើង​អាច​រក្សា​ព័ត៌មាន​សំខាន់​ទុក​នៅ​ក្នុង​ cookie របស់​វា​ដែរ​ឬ​យ៉ាង​ណា​។ ពិនិត្យ​កម្មវិធី​ខាង​ក្រោម​នេះ៖
<!DOCTYPE html>
<html>
  <head>
    <link href='https://fonts.googleapis.com/css?family=Odor+Mean+Chey' rel='stylesheet'>
  </head>
  <body style="font:14px/1.5 'Odor Mean Chey'">
  	

សូម​ចុច​នៅ​​ទី​នេះ​ ដើម្បី​ពិនិត្យ​មើល​ថា​តើ browser អនុញ្ញា​អោយ​មាន cookie ​ដែរ​​ឬ​យ៉ាងណា។

<script> function myFunction() { var cookie = navigator.cookieEnabled?"ពិត​ជាមាន":"គ្មាន​ទេ"; var x = "តើ​មាន Cookies ដែរ​ទេ?: " + cookie; document.getElementById("demo").innerHTML = x; } </script> </body> </html>

សូម​ចុច​នៅ​​ទី​នេះ​ ដើម្បី​ពិនិត្យ​មើល​ថា​តើ browser អនុញ្ញា​អោយ​មាន cookie ​ដែរ​​ឬ​យ៉ាងណា។


នៅ​លើ​បន្ទាត់​លេខ 12 ការសរសេរ​ថា navigator.cookieEnabled គឺ​ជា​ការយក​សម្បត្តិ cookieEnabled នៅ​ក្នុង​វត្ថុ navigator មក​ពិនិត្យ​មើល​ថា តើ browser ពិត​ជា​បាន​អនុញ្ញាត​អោយ​អនុញ្ញាត​អោយ​មាន​ cookie ឬ​យ៉ាង​ណា​។ ចំលើយ​គឺ​ពិត​ជា​មាន​។

Property Description
appCodeName Returns the code name of the browser
appName Returns the name of the browser
appVersion Returns the version information of the browser
cookieEnabled Determines whether cookies are enabled in the browser
geolocation Returns a Geolocation object that can be used to locate the user's position
language Returns the language of the browser
language Returns the language of the browser
onLine Determines whether the browser is online
platform Returns for which platform the browser is compiled
product Returns the engine name of the browser
userAgent Returns the user-agent header sent by the browser to the server