I can’t get this to scroll my blog page smoothly. I have the code correct for sure :
html {
scroll-behavior: smooth;
}
And I also looked through some of my other codes I have here, to see if they may be interfering, such as :
document.getElementById('f1').onsubmit = function() {
findString(this.t1.value);
return false;
};
// press Enter key in search box to remove highlight
$(document).on('keydown',function(e){
if(e.keyCode == 13 ) {
$(".searchTerm").focus()
}
});
$(document).on('keydown',function scrollToTop(e){
if(e.keyCode == 36 ) {
window.scrollTo(0, 0);
}
});
// click on body to remove highlight and clear search
$('body').click(function(){
$(".searchTerm").focus();
});
And my new code I put in yesterday for my search on page :
var TRange = null;
function findString(str) {
if (parseInt(navigator.appVersion) < 4) return;
var strFound;
if (window.find) {
// CODE FOR BROWSERS THAT SUPPORT window.find
strFound = self.find(str);
if (strFound && self.getSelection && !self.getSelection().anchorNode) {
strFound = self.find(str)
}
if (!strFound) {
strFound = self.find(str, 0, 1)
while (self.find(str, 0, 1)) continue
}
} else if (navigator.appName.indexOf("Microsoft") != -1) {
// EXPLORER-SPECIFIC CODE
if (TRange != null) {
TRange.collapse(false)
strFound = TRange.findText(str)
if (strFound) TRange.select()
}
if (TRange == null || strFound == 0) {
TRange = self.document.body.createTextRange()
strFound = TRange.findText(str)
if (strFound) TRange.select()
}
} else if (navigator.appName == "Opera") {
alert("Opera browsers not supported, sorry...")
return;
}
if (!strFound) alert("String '" + str + "' not found!")
return;
};
document.getElementById('f1').onsubmit = function() {
findString(this.t1.value);
return false;
};
Here are the HTML and CSS to that :
<form name="f1" id="f1" action="" class="search">
<br />
<input type="text" class="searchTerm" name="t1" id="results" onfocusin="this.value=''" placeholder="Search blog" value="Search blog" />
<br />
</form>
#f1 input[type=submit] {
display: none;
}
.t1 {
border: 0px solid orange;
padding: 1px 5px;
}
So, I have no idea where may be preventing the smooth scrolling.