Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- < charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- < src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
- </head>
- <body>
- <form>
- <input type="text" id="input1" placeholder="Input 1">
- <input type="text" id="input2" placeholder="Input 2">
- </form>
- <div id="were">
- Content
- </div>
- <>
- function isMobileDevice() {
- return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1);
- };
- if (isMobileDevice()) {
- $("#input1, #input2").on("focus", function () {
- $("html, body").animate({
- scrollTop: $("#were").offset().top
- }, 500);
- });
- }
- </script>
- </body>
- </html>
- //////////////////////
- function isTouchDevice() {
- return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || window.navigator.msMaxTouchPoints > 0;
- }
- if (isTouchDevice()) {
- console.log("This device has a touch screen");
- } else {
- console.log("This device doesn't have a touch screen");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement