aboutsummaryrefslogtreecommitdiff
path: root/files/he/web/api/storage/getitem/index.html
blob: d18fcf9d3dd36298bdb501a03c140aafd298eee6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
title: localStorage.getItem()
slug: Web/API/Storage/getItem
translation_of: Web/API/Storage/getItem
---
<p>{{APIRef("Web Storage API")}}</p>

<p> </p>

<p>פונקציית <strong><code>()getItem</code></strong> מאפשרת לאחזר נתונים מהאחסון המקומי באמצעות שם המפתח.<br>
 במידה והמפתח שרוצים לאחזר אינו קיים באחסון המקומי, יוחזר הערך null.</p>

<h2 id="תחביר">תחביר</h2>

<pre class="syntaxbox">var <em>aValue</em> = localStorage.getItem(<em>keyName</em>);
</pre>

<h3 id="פרמטרים">פרמטרים</h3>

<dl>
 <dt><em><code>keyName</code></em></dt>
 <dd>שם המפתח אותו רוצים לאחזר.</dd>
</dl>

<h3 id="ערך_חוזר">ערך חוזר</h3>

<p>במידה והמפתח קיים באחסון המקומי הוא יחזיר את ערכו. במידה והמפתח אינו קיים יוחזר הערך null.</p>

<h2 id="דוגמאות">דוגמאות</h2>

<p>הפונקציה הבאה מאחזרת שלושה פריטי נתונים מהאחסון המקומי ולאחר מכן משתמשת בהם כדי להגדיר גיליונות סגנון מדורגים.</p>

<pre class="brush: js">function setStyles() {
  var currentColor = localStorage.getItem('bgcolor');
  var currentFont = localStorage.getItem('font');
  var currentImage = localStorage.getItem('image');

  currentColor = document.getElementById('bgcolor').value;
  currentFont = document.getElementById('font').value;
  currentImage = document.getElementById('image').value;

  htmlElem.style.backgroundColor = '#' + currentColor;
  pElem.style.fontFamily = currentFont;
  imgElem.setAttribute('src', currentImage);
}</pre>

<h2 id="מפרט">מפרט</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'webstorage.html#dom-storage-getitem', 'Storage.getItem')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="תאימות_דפדפן">תאימות דפדפן</h2>



<p>{{Compat("api.Storage.getItem")}}</p>

<h2 id="ראו_גם">ראו גם</h2>

<ul>
 <li><a href="https://developer.mozilla.org/he/docs/Web/API/Storage/setItem">()Storage.setItem </a></li>
 <li><a href="/he/docs/Web/API/Storage/removeItem">()Storage.removeItem</a></li>
</ul>