创建不带display-javascript的alert()方法
creating the alert() method without the display - javascript
有没有一种方法可以复制alert()函数的功能,而不弹出??这可能看起来很疯狂,但这是有充分理由的。
编辑
这是我的代码:
var navActive;
var pageID;
var maxNav;
var popWidth = $(window).width();
var popHeight = $(window).height();
function thread_start(callback) {
setTimeout(callback, 1);
return true;
}
(function($){
$.fn.foneySlide = function ( options ) {
$(window).resize(function(){
popWidth = $(window).width() - 40;
popHeight = $(window).height() - 40;
})
opt = $.extend ({ popOnTransition : true }, options);
// firstly give all navigation items a position reference for continous slide
$('[data-role=page]').each(function(i){
$(this).attr('navpos', i );
if( typeof $('[data-role=page]')[i+1] == 'undefined' ) {
maxNav = i;
}
});
// get the current active page and the default navigation position
pageID = $('.ui-page-active').attr('id');
navActive = $('#' + pageID).attr('navpos');
// change page on swipe left
$('body').bind('swipeleft', function(e){
if( navActive == maxNav ) {
navActive = 0;
alert();
thread_start("$.mobile.changePage($('[navpos=0]'), 'slide', false, true)");
}else{
navActive = Number(navActive + 1);
alert();
thread_start("$.mobile.changePage($('[navpos=' + navActive + ']'), 'slide', false, true)");
}
});
// change page on swipe right
$('body').bind('swiperight', function(e){
if( navActive == 0 ) {
navActive = maxNav;
alert();
thread_start("$.mobile.changePage($('[navpos=' + navActive + ']'), 'slide', true, true)");
}else{
navActive = Number(navActive - 1);
alert();
thread_start("$.mobile.changePage($('[navpos=' + navActive + ']'), 'slide', true, true)");
}
});
}
})(jQuery);
删除警报,它就会开始冻结。
我不知道这是否是你想要的,但我经常使用firebug和console.log调用来获取有关javascript正在做什么的信息,而不会干扰网站流。
但是,请记住,如果它是一个实时站点,请绕过console.log方法,因为任何没有firebug的人都会收到错误。
if(typeof console == 'undefined') {
console = function(){}
console.log = function(txt){}
console.warn = function(txt){}
} else console.log('Console Active');
获取Firebug站点
阅读您的注释但不了解您的代码,这就是您想要实现的吗?
之前:
function something() {
a();
b(); // needs a pause before executing c()
c();
}
之后:
function something() {
a();
b(); // needs a pause before executing c()
setTimeout(c,10);
}
警报只有一个单独的用途,那就是显示一个弹出窗口,所以我想知道是什么原因…:)
但这是可能的,正如在SO.上所展示的那样
function alert(msg)
{
// Ignore
}
window.alert = function(text) { }
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- angularJS:window.alert仅在方法完成后
- Watir WebDriver:未定义的方法“alert”
- 不能在 jQuery 方法中使用 alert()
- alert() 方法不会导致 window.focus on modern browsers
- 未捕获的类型错误:对象#<HTML文档>没有方法'alert'
- 重写默认的浏览器alert()方法
- 在使用alert方法时,是否应该在javascript中指定父对象
- 斜体字在Javascript中不起作用'alert()'方法
- 像alert()这样的声明方法是否会覆盖Javascript中内置的alert()方法?
- & lt; br>在alert()方法中删除PRE标记的内容
- Alert不会在onSubmit方法中被调用
- 为什么document.write()和alert()方法呈现JavaScript对象的方式不同?
- WebDriver's executeScript返回alert文本,而不是JavaScript方法返回的值
- 有什么方法可以强制Internet Explorer打开alert()吗
- 有没有一种方法可以像alert()函数那样在JavaScript中强制同步行为
- 创建不带display-javascript的alert()方法
- 延迟作业的回调方法-render js alert
- 由 alert() 修复的 JavaScript 方法处理