简体   繁体   English

如何在JavaScript内添加bootstrap-alert框?

[英]how to add bootstrap-alert box inside a javascript?

I have a JavaScript with alert box saying some text when an image is uploaded with wrong dimension.I want to show that alert as a Bootstrap alert instead of a popup window? 我有一个带警报的JavaScript框,当以错误的尺寸上传图像时会说一些文本。我想将该警报显示为Bootstrap警报而不是弹出窗口?

I have a separate JavaScript file. 我有一个单独的JavaScript文件。

In Bootstrap they're not called "pop ups", but instead modals. 在Bootstrap中,它们不称为“弹出窗口”,而是模式。 Its the same general principle (a alert onto the screen for the user to interact with), but just more pretty. 它具有相同的一般原理(向用户发送警报到屏幕上进行交互),但更加美观。 See the link below for more information on modals, and the code as well (fully functional). 请参阅下面的链接,以获取有关模态以及代码(功能齐全)的更多信息。 Hope this helps. 希望这可以帮助。 - Jusitn -Jusitn

Link: http://www.w3schools.com/bootstrap/bootstrap_modal.asp 链接: http//www.w3schools.com/bootstrap/bootstrap_modal.asp

Edit: Dont forget to add the bootstrap CDN's for it to work (both the CSS and Javascript CDNs) between your head tags 编辑:别忘了添加引导CDN使其在您的head标签之间工作(CSS和Javascript CDN)

CDN can be found here: http://www.bootstrapcdn.com/ CDN可以在这里找到: http : //www.bootstrapcdn.com/

Code: 码:

<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
        <p>Some text in the modal.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM