Skip to content

Commit d8f071a

Browse files
authored
Merge pull request #1 from manthanank/new-changes
feat: updated
2 parents 0fd8318 + 197cfca commit d8f071a

File tree

1 file changed

+159
-11
lines changed

1 file changed

+159
-11
lines changed

README.md

+159-11
Original file line numberDiff line numberDiff line change
@@ -2725,8 +2725,20 @@ Web API is an application programming interface for the Web.
27252725
27262726
`checkValidity()` - Returns true if an input element contains valid data.
27272727
2728-
```javascript
2728+
```html
2729+
<input id="id1" type="number" min="100" max="300" required>
2730+
<button onclick="myFunction()">OK</button>
2731+
2732+
<p id="demo"></p>
2733+
```
27292734
2735+
```javascript
2736+
function myFunction() {
2737+
const inpObj = document.getElementById("id1");
2738+
if (!inpObj.checkValidity()) {
2739+
document.getElementById("demo").innerHTML = inpObj.validationMessage;
2740+
}
2741+
}
27302742
```
27312743
27322744
`setCustomValidity()` - Sets the validationMessage property of an input element.
@@ -2771,14 +2783,38 @@ Web API is an application programming interface for the Web.
27712783
27722784
`rangeOverflow` - Set to true, if an element's value is greater than its max attribute.
27732785
2774-
```jsx
2786+
```html
2787+
<input id="id1" type="number" max="100">
2788+
<button onclick="myFunction()">OK</button>
2789+
2790+
<p id="demo"></p>
2791+
```
27752792
2793+
```jsx
2794+
function myFunction() {
2795+
let text = "Value OK";
2796+
if (document.getElementById("id1").validity.rangeOverflow) {
2797+
text = "Value too large";
2798+
}
2799+
}
27762800
```
27772801
27782802
`rangeUnderflow` - Set to true, if an element's value is less than its min attribute.
27792803
2780-
```jsx
2804+
```html
2805+
<input id="id1" type="number" max="100">
2806+
<button onclick="myFunction()">OK</button>
2807+
2808+
<p id="demo"></p>
2809+
```
27812810
2811+
```jsx
2812+
function myFunction() {
2813+
let text = "Value OK";
2814+
if (document.getElementById("id1").validity.rangeUnderflow) {
2815+
text = "Value too small";
2816+
}
2817+
}
27822818
```
27832819
27842820
`stepMismatch` - Set to true, if an element's value is invalid per its step attribute.
@@ -2818,65 +2854,177 @@ Web History API provides easy methods to access the windows.history object.
28182854
`History back()` Method
28192855
28202856
```javascript
2821-
2857+
function myFunction() {
2858+
window.history.back();
2859+
}
28222860
```
28232861
28242862
`History go()` Method
28252863
28262864
```javascript
2827-
2865+
function myFunction() {
2866+
window.history.go(-2);
2867+
}
28282868
```
28292869
28302870
**History Object Properties** -
28312871
28322872
`length` - Returns the number of URLs in the history list
28332873
28342874
```javascript
2835-
2875+
history.length
28362876
```
28372877
28382878
**History Object Methods** -
28392879
28402880
`back()` - Loads the previous URL in the history list
28412881
28422882
```javascript
2843-
2883+
history.back()
28442884
```
28452885
28462886
`forward()` - Loads the next URL in the history list
28472887
28482888
```javascript
2849-
2889+
history.forward()
28502890
```
28512891
28522892
`go()` - Loads a specific URL from the history list
28532893
28542894
```javascript
2855-
2895+
history.go()
28562896
```
28572897
28582898
**Storage API** -
28592899
2900+
Web Storage API is a simple syntax for storing and retrieving data in the browser.
2901+
2902+
The localStorage Object -
2903+
2904+
The localStorage object provides access to a local storage for a particular Web Site. It allows you to store, read, add, modify, and delete data items for that domain.
2905+
2906+
setItem() Method
2907+
28602908
```javascript
2909+
localStorage.setItem("name", "Manthan Ankolekar");
2910+
```
28612911
2912+
getItem() Method
2913+
2914+
```javascript
2915+
localStorage.getItem("name", "Manthan Ankolekar");
28622916
```
28632917
2864-
**Worker API** -
2918+
sessionStorage Object -
2919+
2920+
The sessionStorage object is identical to the localStorage object. The difference is that the sessionStorage object stores data for one session.
2921+
2922+
getItem() Method
2923+
2924+
```javascript
2925+
sessionStorage.getItem("name");
2926+
```
2927+
2928+
setItem() Method
28652929
28662930
```javascript
2931+
sessionStorage.setItem("name", "Manthan Ankolekar");
2932+
```
2933+
2934+
Storage Object Properties and Methods
2935+
2936+
key(n) - Returns the name of the nth key in the storage
2937+
2938+
```jsx
2939+
localStorage.key(index)
2940+
sessionStorage.key(index)
2941+
```
2942+
2943+
length - Returns the number of data items stored in the Storage object
2944+
2945+
```jsx
2946+
localStorage.length;
2947+
sessionStorage.length;
2948+
```
2949+
2950+
getItem(keyname) - Returns the value of the specified key name
2951+
2952+
```jsx
2953+
localStorage.getItem(keyname)
2954+
sessionStorage.getItem(keyname)
2955+
```
2956+
2957+
setItem(keyname, value) - Adds a key to the storage, or updates a key value (if it already exists)
2958+
2959+
```jsx
2960+
localStorage.setItem(keyname, value)
2961+
sessionStorage.setItem(keyname, value)
2962+
```
2963+
2964+
removeItem(keyname)- Removes that key from the storage
2965+
2966+
```jsx
2967+
localStorage.removeItem(keyname)
2968+
sessionStorage.removeItem(keyname)
2969+
```
2970+
2971+
clear() - Empty all key out of the storage
2972+
2973+
```jsx
2974+
localStorage.clear()
2975+
sessionStorage.clear()
2976+
```
2977+
2978+
Related Pages for Web Storage API
2979+
2980+
window.localStorage - Allows to save key/value pairs in a web browser. Stores the data with no expiration date
2981+
2982+
```jsx
2983+
window.localStorage
2984+
2985+
localStorage
2986+
```
2987+
2988+
window.sessionStorage - Allows to save key/value pairs in a web browser. Stores the data for one session
28672989
2990+
```jsx
2991+
window.sessionStorage
2992+
2993+
sessionStorage
28682994
```
28692995
2996+
**Worker API** -
2997+
2998+
A web worker is a JavaScript running in the background, without affecting the performance of the page.
2999+
28703000
**Fetch API** -
28713001
2872-
```javascript
3002+
The Fetch API interface allows web browser to make HTTP requests to web servers.
28733003
3004+
```javascript
3005+
fetch(file)
3006+
.then(x => x.text())
3007+
.then(y => myDisplay(y));
28743008
```
28753009
28763010
**GeoLocation API** -
28773011
3012+
The HTML Geolocation API is used to get the geographical position of a user.
3013+
28783014
```javascript
3015+
const x = document.getElementById("demo");
3016+
function getLocation() {
3017+
if (navigator.geolocation) {
3018+
navigator.geolocation.getCurrentPosition(showPosition);
3019+
} else {
3020+
x.innerHTML = "Geolocation is not supported by this browser.";
3021+
}
3022+
}
28793023

3024+
function showPosition(position) {
3025+
x.innerHTML = "Latitude: " + position.coords.latitude +
3026+
"<br>Longitude: " + position.coords.longitude;
3027+
}
28803028
```
28813029
28823030
## AJAX

0 commit comments

Comments
 (0)