Hi how i can make show a web page only to people with chrome 18 ? , and if they do not have chrome 18 the page should not be displayed , how can I create something like this using a html code ? and also if they have firefox or safari the webpage must not be appear
Asked
Active
Viewed 45 times
0
-
I think you'll need javascript for this, as in the answers to [this question](http://stackoverflow.com/questions/2400935/browser-detection-in-javascript) – Jamie Bull Jan 22 '17 at 10:02
-
Possible duplicate of [Browser detection in JavaScript?](http://stackoverflow.com/questions/2400935/browser-detection-in-javascript) – Muhammad Saqlain Jan 22 '17 at 10:03
1 Answers
1
1) Put the content you want to only show to Chrome 18 users in a <div>
, with display: none;
in its style:
<div id="hiddenContent" style="display: none;">
My hidden content.
</div>
2) Add a <script>
tag, with the following code:
function GetChromeVersion() {
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
return raw ? parseInt(raw[2], 10) : false;
}
if (GetChromeVersion() == 18)
document.getElementById("hiddenContent").style.display = "";
Here's a live example:
<div id="hiddenContent" style="display: none;">
My hidden content.
</div>
<script>
function GetChromeVersion() {
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
return raw ? parseInt(raw[2], 10) : false;
}
if (GetChromeVersion() == 18)
document.getElementById("hiddenContent").style.display = "";
</script>

Venryx
- 15,624
- 10
- 70
- 96