문제

When I run the below code for Modernizr to check for range it's not giving me the expected result. The function is called though the condition is true or not. What I'm trying to do is to run the function only when the range input type is not supported by the browser otherwise it should not be called.

<!DOCTYPE html>
<html>
<head>
<script src="modernizrdev.js"></script>
<script>
if(!Modernizr.range)
{
document.write("Your browser version does not support range");
}
</script>
</head>
<body>

<form action="demo_form.asp" method="get">
Points: 0<input type="range" name="points" min="1" max="10">10
<input type="submit">
</form>
</body>
</html>
도움이 되었습니까?

해결책

you can try this

if(!Modernizr.inputtypes.range)
{
    document.write("Your browser version does not support range");
}

다른 팁

If I understand the docs correctly it is:

<!DOCTYPE html>
<html>
<head>
<script src="modernizrdev.js"></script>
<script>
if(!Modernizr.inputtypes.range)
{
document.write("Your browser version does not support range");
}
</script>
</head>
<body>

<form action="demo_form.asp" method="get">
Points: 0<input type="range" name="points" min="1" max="10">10
<input type="submit">
</form>
</body>
</html>

More info: http://www.browserleaks.com/modernizr

I think you might need

Modernizr.inputtypes.range
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top