ctx.beginPath(); ctx.rect(10, 10, 30, 30); ctx.fill(); if (ctx.scrollPathIntoView) { ctx.scrollPathIntoView(); } else { ctx.fillText("Your browser does not support 'scrollPathIntoView()'.", 0, 150); }