File tree 3 files changed +55
-0
lines changed
JavaScript/Advance/Web API/Intro
3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+
4
+ < head >
5
+ < meta charset ="UTF-8 ">
6
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
7
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
8
+ < title > Web-API-Inro</ title >
9
+ < link rel ="shortcut icon " href ="images/js-logo.png " type ="image/x-icon ">
10
+ </ head >
11
+
12
+ < body >
13
+ < h1 > Web API Intoduction</ h1 >
14
+ < p id ="textOne "> </ p >
15
+ < button onclick ="DisplayOne() "> Click to View Doc</ button >
16
+ < h2 > Example</ h2 >
17
+ < button onclick ="getLocation() "> Get Location</ button >
18
+ < p id ="textTwo "> </ p >
19
+ < script src ="script.js "> </ script >
20
+ </ body >
21
+
22
+ </ html >
Original file line number Diff line number Diff line change
1
+ // Mention All the Documents and Info about Web API's
2
+ let textOne = document . getElementById ( 'textOne' ) ;
3
+
4
+ function DisplayOne ( ) {
5
+ textOne . innerHTML = `
6
+ <h3>A Web API is a developer's dream.</h3>
7
+ <li>It can extend the functionality of the browser</li>
8
+ <li>It can greatly simplify complex functions</li>
9
+ <li>It can provide easy syntax to complex code</li>
10
+ <h1>What is Web API?</h1>
11
+ <p>API stands for Application Programming Interface.</p>
12
+ <p>A Web API is an application programming interface for the Web.</p>
13
+ <p>A Browser API can extend the functionality of a web browser.</p>
14
+ <p>A Server API can extend the functionality of a web server.</p>
15
+ `
16
+ }
17
+
18
+
19
+ // Example For Understanding Web API
20
+
21
+ let textTwo = document . getElementById ( 'textTwo' ) ;
22
+
23
+ function getLocation ( ) {
24
+ try {
25
+ navigator . geolocation . getCurrentPosition ( showLocation ) ;
26
+ } catch {
27
+ textTwo . innerHTML = "Error Just Happened" ;
28
+ }
29
+ }
30
+
31
+ function showLocation ( position ) {
32
+ textTwo . innerHTML = "Latitude= " + position . coords . latitude + "<br> Longitude= " + position . coords . longitude ;
33
+ }
You can’t perform that action at this time.
0 commit comments