hello every one
I work on HTML File for my app
i need to get value from URL ?
as example https://www.codeproject.com/5225378
how to get 5225378 from url and show it as text in the html ?
any one know how to do that in HTML File
THANK YOU
hello every one
I work on HTML File for my app
i need to get value from URL ?
as example https://www.codeproject.com/5225378
how to get 5225378 from url and show it as text in the html ?
any one know how to do that in HTML File
THANK YOU
thank you muneer not that what i mean
i need Html code to do that to use it in the web viewer
Can you explain more?
Do you want to change the number part of the URL to another number?
look this for example my URL https://www.codeproject.com/5225378
how i can take the number after the slash 5225378 and displayed it as a Title in my HTML page
look muneer this code you write it for me 5 months ago
this code will take the url after the “showURL” word and displayed it in the iframe
what i need is the same but to displayed it as a text in the HTML page
sorry about my bad language i know it hard to you to understand me thank you
Try this. If you use it in your browser and add any parameter to it you will see it in the HTML page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example for Bader</title>
</head>
<body>
<h4>Text will show here</h4>
<p id='exampleMsg'></p>
<script>
const partURL = new URLSearchParams(window.location.search);
console.log(partURL);
document.getElementById('exampleMsg').innerHTML = partURL;
</script>
</body>
</html>
See this result
thank you muneer that exactly what u need
but can i add something to this code just to show parameter after word “SHOW”
Yes of course.
Change the line
document.getElementById('exampleMsg').innerHTML = partURL;
To the following
document.getElementById('exampleMsg').innerHTML = partURL.get('test');
Now you will see whatever you type in the URL after test=.
it work THANK YOU for this fast solution
the last question please
is that possible to have tow (test) word in the url so i can get 2 value ?
like this - i try this put not work
Yes, you can
what i should to do
can you please tell me how ?
See this code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example for Bader</title>
</head>
<body>
<h4>Text will show here</h4>
<p id='showMsg'></p>
<script>
const partURL = new URLSearchParams(window.location.search);
let textToShow = '';
if (partURL.has('test')){
textToShow += partURL.get('test');
}
if (partURL.has('demo')){
textToShow += '<br>' + partURL.get('demo');
}
if (textToShow.length > 0) {
document.getElementById('showMsg').innerHTML = textToShow
} else {
document.getElementById('showMsg').innerHTML = 'no data';
}
</script>
</body>
Sample output
Thank you munir but that not what I mean
I need each ID alone to use each word alone
Not to show the massage in one ID
THANK YOU
Use this one then
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example for Bader</title>
</head>
<body>
<h4>Text will show here</h4>
<p id='showMsg1'></p>
<p id='showMsg2'></p>
<script>
const partURL = new URLSearchParams(window.location.search);
document.getElementById('showMsg1').innerHTML = partURL.get('test');
document.getElementById('showMsg2').innerHTML = partURL.get('demo');
</script>
</body>
Thank you so much muneer
Now it’s work 100% as I need