Skip to content

Commit b5b7a97

Browse files
authored
Update index.html
1 parent 43068c7 commit b5b7a97

1 file changed

Lines changed: 53 additions & 75 deletions

File tree

index.html

Lines changed: 53 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,13 @@ <h3>1. Change the Content of an Element</h3>
124124
</pre>
125125

126126
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
127-
<!--~~~~~~~~~~~~~~~~~~~~~~~ 01. change content using innerHTML ~~~~~~~~~~~~~~~~-->
128-
<p align="center" >
129-
<a href=""
130-
target="_blank" rel="noopener noreferrer">
131-
<img class="displayed"
127+
<!--~~~~~~~~~~~~~~~~~~~~~~~~ 01. example change content using innerHTML ~~~~~~~~~~~~~~~~~~~~~~~~-->
128+
<img class="displayed"
132129
src="./images/image001.gif?raw=true"
133130
loading="lazy"
134-
style="width:40%;"
135-
title=""
136-
alt="." />
137-
</a>
138-
</p>
131+
style="width:531px; height:94px;"
132+
title="Example changing content using innerHTML"
133+
alt="Example changing content using innerHTML." />
139134
<!-- image001.gif -->
140135
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
141136
<h4>In this example</h4>
@@ -1763,20 +1758,21 @@ <h1 style="color: green">
17631758

17641759
</html>
17651760
</pre>
1766-
17671761
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
17681762
<h4>Output:</h4>
17691763
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
1770-
<!--~~~~~~~~~~~~~~~~~~~~~~~ 39. ~~~~~~~~~~~~~~~~-->
1764+
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~ 39. g4g - listing url and hostname ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
17711765
<p align="center" >
17721766
<a href=""
17731767
target="_blank" rel="noopener noreferrer">
17741768
<img class="displayed"
17751769
src="./images/image039.png?raw=true"
17761770
loading="lazy"
17771771
style="width:40%;"
1778-
title=""
1779-
alt="." />
1772+
title="GeeksforGeeks URL is: https://ide.geeksforgeeks.org/tryit.php,
1773+
hostname is: ide.geeksforgeeks.org"
1774+
alt="GeeksforGeeks URL is: https://ide.geeksforgeeks.org/tryit.php,
1775+
hostname is: ide.geeksforgeeks.org." />
17801776
</a>
17811777
</p>
17821778
<!-- image039.png -->
@@ -1794,24 +1790,22 @@ <h4>Syntax</h4>
17941790
<h4>Example: In this example, we will ask for the URL to the user and then will perform the
17951791
extraction of the hostname on that URL.</h4>
17961792
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
1797-
17981793
<pre>
1799-
<!DOCTYPE html>
1800-
<html>
1801-
1802-
<head>
1803-
<title>Extracting URL</title>
1804-
</head>
1794+
&lt;!DOCTYPE html&gt;
1795+
&lt;html&gt;
1796+
&lt;head&gt;
1797+
&lt;title&gt;Extracting URL</title&gt;
1798+
&lt;/head&gt;
18051799

1806-
<body>
1807-
<h1 style="color: green;">GeeksforGeeks</h1>
1808-
<b>Extracting URL</b>
1809-
<br><br>
1810-
<form name="f1">
1811-
<input type="text" name="txt" placeholder="Paste URL" />
1812-
<input type="button" value="click" onclick="url2()" />
1813-
</form>
1814-
<script>
1800+
&lt;body&gt;
1801+
&lt;h1 style="color: green;"&gt;GeeksforGeeks&lt;/h1&gt;
1802+
&lt;b&gt;Extracting URL&lt;/b&gt;
1803+
&lt;br&gt;&lt;br&gt;
1804+
&lt;form name="f1"&gt;
1805+
&lt;input type="text" name="txt" placeholder="Paste URL" /&gt;
1806+
&lt;input type="button" value="click" onclick="url2()" /&gt;
1807+
&lt;/form&gt;
1808+
&lt;script&gt;
18151809
function url2() {
18161810

18171811
let url3 = document.f1.txt.value;
@@ -1820,7 +1814,7 @@ <h1 style="color: green;">GeeksforGeeks</h1>
18201814

18211815
let host = "";
18221816

1823-
for (i = j + 3; i < url3.length; i++) {
1817+
for (i = j + 3; i &lt; url3.length; i++) {
18241818
if (url3.charAt(i) != '/') {
18251819
host = host + "" + url3.charAt(i);
18261820
} else {
@@ -1829,12 +1823,11 @@ <h1 style="color: green;">GeeksforGeeks</h1>
18291823
}
18301824
document.write(host);
18311825
}
1832-
</script>
1833-
</body>
1826+
&lt;/script&gt;
1827+
&lt;/body&gt;
18341828

1835-
</html>
1829+
&lt;/html&gt;
18361830
</pre>
1837-
18381831
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
18391832
<h4>Output:</h4>
18401833
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
@@ -1867,17 +1860,15 @@ <h4>Syntax</h4>
18671860
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
18681861
<h4>Return Value: It returns a string value that represents the full URL of the document.</h4>
18691862
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
1870-
18711863
<pre>
1872-
<script>
1864+
&lt;script&gt;
18731865
// Get the current URL using document.URL
18741866
let currentUrl = document.URL;
18751867

18761868
// Log the URL to the console
18771869
console.log(currentUrl);
1878-
</script>
1870+
&lt;/script&gt;
18791871
</pre>
1880-
18811872
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
18821873
<h4>Output</h4>
18831874
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
@@ -1894,13 +1885,13 @@ <h4>Syntax</h4>
18941885
<pre>window.location.href</pre>
18951886

18961887
<pre>
1897-
<script>
1888+
&lt;script&gt;
18981889
// Get the current URL using document.URL
18991890
let currentUrl = document.URL;
19001891

19011892
// Log the URL to the console
19021893
console.log(currentUrl);
1903-
</script>
1894+
&lt;/script&gt;
19041895
</pre>
19051896

19061897
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
@@ -1935,7 +1926,6 @@ <h3 id="D12-01">Method 1: Using the URLSearchParams Object</h3>
19351926
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
19361927
<h4>Syntax:</h4>
19371928
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
1938-
19391929
<pre>
19401930
let paramString = urlString.split('?')[1];
19411931
let queryString = new URLSearchParams(paramString);
@@ -1944,38 +1934,36 @@ <h4>Syntax:</h4>
19441934
console.log("Value is: " + pair[1]);
19451935
}
19461936
</pre>
1947-
19481937
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
19491938
<h4>Example: In this example we retrieves URL parameters using JavaScript. It splits the URL,
19501939
extracts parameters with <b><mark>URLSearchParams()</mark></b>, and logs each
19511940
<b><mark>key-value</mark></b> pair to the console when the button is clicked.</h4>
19521941
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
1953-
19541942
<pre>
1955-
<!DOCTYPE html>
1956-
<html>
1957-
<head>
1958-
<title>
1943+
&lt;!DOCTYPE html&gt;
1944+
&lt;html&gt;
1945+
&lt;head&gt;
1946+
&lt;title&gt;
19591947
How To Get URL Parameters using JavaScript?
1960-
</title>
1961-
</head>
1962-
<body>
1963-
<h1 style="color:green;">
1948+
&lt;/title&gt;
1949+
&lt;/head&gt;
1950+
&lt;body&gt;
1951+
&lt;h1 style="color:green;"&gt;
19641952
GeeksforGeeks
1965-
</h1>
1966-
<b>
1953+
&lt;/h1&gt;
1954+
&lt;b&gt;
19671955
How To Get URL Parameters
19681956
With JavaScript?
1969-
</b>
1970-
<p> The url used is:
1957+
&lt;/b&gt;
1958+
&lt;p&gt; The url used is:
19711959
https://www.example.com/login.php?a=GeeksforGeeks&b=500&c=Hello Geeks
1972-
</p>
1973-
<p>
1960+
&lt;/p&gt;
1961+
&lt;p&gt;
19741962
Click on the button to get the url
19751963
parameters in the console.
1976-
</p>
1977-
<button onclick="getParameters()"> Get URL parameters </button>
1978-
<script>
1964+
&lt;/p&gt;
1965+
&lt;button onclick="getParameters()"&gt; Get URL parameters &lt;/button&gt;
1966+
&lt;script&gt;
19791967
function getParameters() {
19801968
let urlString =
19811969
"https://www.example.com/login.php?a=GeeksforGeeks&b=500&c=Hello Geeks";
@@ -1986,11 +1974,10 @@ <h1 style="color:green;">
19861974
console.log("Value is:" + pair[1]);
19871975
}
19881976
}
1989-
</script>
1990-
</body>
1991-
</html>
1992-
</pre>
1993-
1977+
&lt;/script&gt;
1978+
&lt;/body&gt;
1979+
&lt;/html&gt;
1980+
</pre&gt;
19941981
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
19951982
<h4>Output:</h4>
19961983
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
@@ -2633,12 +2620,3 @@ <h4>Output:</h4>
26332620
<!- script was here -->
26342621
</body>
26352622
</html>
2636-
2637-
2638-
2639-
2640-
2641-
2642-
2643-
2644-

0 commit comments

Comments
 (0)