【问题标题】:Adding custom dialog box in Javascript?在Javascript中添加自定义对话框?
【发布时间】:2011-12-20 05:25:37
【问题描述】:

我想添加一个自定义对话框来获取“是”、“否”或“注册”、“取消”等文本。 我不想使用任何框架。目前我正在使用 jQuery 来实现这一点。请帮助使用带有 Javascript 的 CSS3 和 HTML5 来完成它!

我当前的代码:

apprise('Do you wish to use the existing details?', {'verify':true}, function(r)  }  

【问题讨论】:

  • 这和安卓有什么关系?您是说您不再想使用 jQuery(如果是,那有什么原因)?您提供的代码不完整/不正确。 apprise 函数是什么?
  • appraise 是一种 jQuery 方式。我正在 android 中开发一个混合应用程序
  • 您的意思是plugin 在您的问题中从未提及?我不知道什么是混合应用程序,但是如果你可以使用 Javascript,并且你有 HTML,那么你没有理由不能使用 jQuery。

标签: javascript android css


【解决方案1】:
If(!confirm('Do you wish to use the existing details?')){
   return false;
}else{
    //If yes
    // Code here
}

//Or just continue here

回复您的评论:

<div class='myMesssage' style='display:none'>
    <div class='content'>

    </div>
    <div class='buttons'>
        <input type='button' class='yesB' value='Yes'/> <input class='yesB' type='button' value='No'/>
    </div>
</div>

JS:

function openMsg(msg){
    $(".myMessage .content").html(msg);
    $(".myMessage .buttons .yesB").click(function(){
            //Button function here, you could make this dynamic
           $(".myMessage").toggle();
     });

    $(".myMessage").toggle();
}

使用这种方法,您确实需要稍微改变您的逻辑,因为现在,流程应该从消息中的按钮按下继续。但这很容易通过将函数动态分配给 .yesB 的点击事件

【讨论】:

  • 这将为我提供“确定”和“取消”按钮。
  • 是的,我认为这就是您要找的东西。否则,只需创建一个 Div,并按照您喜欢的方式设置样式,并在其上添加您喜欢的按钮,然后将其隐藏,直到必须弹出消息,这样您就可以完全控制。
  • 它不适合我。它对我没有任何显示! ?我不是js专家。所以可能错过了什么!
  • 你打电话了吗 openMsg('Hello world');或类似的东西?当然,您确实需要设置消息 div 的样式,这不是一个准备就绪的包。
猜你喜欢
  • 2011-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-19
  • 1970-01-01
相关资源
最近更新 更多