I have this line of Javascript:
if (true){
$('#custom-tag').html('HTML');
}
else {
$('#custom-tag').html('DifferentHTML');
}
If a variable is yes, it will run this html code at startup. If the variable is not yes, then it will run this line of html at startup. How can I do this?
EDIT: I'm afraid I forgot to say, I was wanting this to detect your browser. If using chrome, it will put out no HTML. If using other browsers than chrome, it will put out HTML.
EDIT#2: I have this code. I need to fix this for the popup that identifies if it's chrome.
$(function() {
$('#in').on('keyup', function() {
validate();
});
});
function validate() {
var x = $('#in').val();
if (navigator.userAgent.indexOf("Chrome") != -1) {
$('#result').html('<h3>Chrome</h3>');
} else {
$('#result').html('');
}
}
<input type="text" id="in" onChange="validate()" />
<div id="result">
<div id="popup" class="overlay">
<div class="popup">
<h2>Browser</h2>
<a class="close" href="javascript:popupClose();">×</a>
<div class="content">
</div>
</div>
</div>
Just need to connect all of these. EDIT: I need to add the last line of html into the java code if it's not chrome.