对于内置的javascript方法,有可能改变浏览器的默认行为吗?
例如:
从jQuery移动设备调用alert()会创建一个非主题对话框。如果覆盖浏览器的默认警告()行为,并将其替换为一个巧妙的jQuery移动主题对话框,那就太好了?
我知道在jQuery移动版中有很多创建主题对话框的选项,但是如果可以创建一个小型的javascript库来拦截对alert()的调用,那就太好了。
发布于 2012-02-10 22:05:35
您不能设置JavaScript警报的样式,如果您需要设置样式,请使用对话框。如果谷歌搜索的话,应该会有很多例子。
发布于 2012-02-10 22:59:27
查看主题对话框的jQueryMobile插件:http://dev.jtsage.com/jQM-SimpleDialog/index.html
发布于 2018-09-17 15:56:17
Using this code you can override the default alert function in javascript and we can do actions based on the alert message. The default alert function will also work same with this.
(function () {
var _alert = window.alert;
window.alert = function (str) {
if (str == 'Invalid Sesssion')
window.location = "http://www.mywebsite.com/";
_alert(str);
};
})();https://stackoverflow.com/questions/9228250
复制相似问题