i need this function to enable vertical scrolling but not horizontal.
This doesn't works:
function scrollFunction() {
// Scroll to top
document.getElementsByTagName('body')[0].style.overflow-y='auto';
}
While this does, but it enables both vertical and horizontal scrolling.
function scrollFunction() {
// Scroll to top
document.getElementsByTagName('body')[0].style.overflow='auto';
}
How can I specify just the overflow-y properly? Thanks
i need this function to enable vertical scrolling but not horizontal.
This doesn't works:
function scrollFunction() {
// Scroll to top
document.getElementsByTagName('body')[0].style.overflow-y='auto';
}
While this does, but it enables both vertical and horizontal scrolling.
function scrollFunction() {
// Scroll to top
document.getElementsByTagName('body')[0].style.overflow='auto';
}
How can I specify just the overflow-y properly? Thanks
Share Improve this question asked Feb 28, 2013 at 21:16 ChainChain 6273 gold badges9 silver badges24 bronze badges2 Answers
Reset to default 10Compound style properties are written in camelCase notation (the first letter is small):
document.getElementsByTagName("body")[0].style.overflowY = "auto";
As an alternative to VisioN's answer you can use square brackets and a string to access it:
document.getElementByTagName("body")[0].style['overflow-y'] = "auto";
This is good if you don't know what the camelCase is.