Below code is the example can shake your browser window by javascript function shakeBrowserWindow() {
var intensity = 10; // Intensity of the shake
var duration = 500; // Duration of the shake in milliseconds
var start = null;
function step(timestamp) {
if (!start) start = timestamp;
var progress = timestamp - start;
window.moveBy(Math.sin(progress / duration * Math.PI) * intensity, 0);
if (progress < duration) {
window.requestAnimationFrame(step);
}
}
window.requestAnimationFrame(step);
}
// Call the function to shake the browser window
shakeBrowserWindow();
You can execute this code in the browser's developer console or incorporate it into an HTML document. However, note that browser security settings may prevent scripts from moving windows in certain situations.
Tags: HTML Javascript moveBy
|