创建不带display-javascript的alert()方法
有没有一种方法可以在没有弹出窗口的情况下复制alert()函数的功能??这可能看起来很疯狂,但这是有充分理由的 编辑 这是我的密码:创建不带display-javascript的alert()方法,javascript,alert,Javascript,Alert,有没有一种方法可以在没有弹出窗口的情况下复制alert()函数的功能??这可能看起来很疯狂,但这是有充分理由的 编辑 这是我的密码: var navActive; var pageID; var maxNav; var popWidth = $(window).width(); var popHeight = $(window).height(); function thread_start(callback) { setTimeout(callback, 1); return
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');
阅读您的评论但不了解您的代码,这就是您想要实现的目标吗 之前:
function something() {
a();
b(); // needs a pause before executing c()
c();
}
之后:
function something() {
a();
b(); // needs a pause before executing c()
setTimeout(c,10);
}
没有弹出窗口的警报是什么?没有弹出窗口的警报功能是什么?假设警报只显示一个弹出窗口,我想知道如果您不想要弹出窗口,预期结果会是什么。这就像把太阳从暑假中带走一样。你只剩下,什么也没有:-)这是个好问题。我正在为移动设备上的小型网站创建一个移动页面滑块插件,这些网站不需要导航(因为空间),所以它们可以简单地将手指滑动到下一页。jqueryMobile$.mobile.ChangePage()函数在大多数设备上都会冻结,一旦用户向下滚动(根据我测试的结果),它就无法工作。如果我在触发slideLeft事件之前和之后粘贴alert(),然后关闭alert框,所有内容都会很好地滑动。因此,我想知道alert()函数在幕后做了什么。我认为这和我刚才添加的示例一样简单。javascript中的全局上下文实际上位于窗口对象内部,因此重新声明警报函数将覆盖它。但是如果您遇到特定错误,如果您发布代码和收到的错误,这将非常有用。
function something() {
a();
b(); // needs a pause before executing c()
c();
}
function something() {
a();
b(); // needs a pause before executing c()
setTimeout(c,10);
}