小编jgi*_*ich的帖子

捕获所有javascript未处理的异常

我正在尝试找到或找出一种在警报框中显示应用程序中所有未处理的javascript异常的方法.我希望所有这些都在客户端完成,而不使用任何服务器端代码.我正在使用MVC3作为环境.

我过去几天一直在研究,并没有找到我正在寻找的东西.

我发现下面有两种方式,看起来它们几乎就是我正在寻找的东西,除了这些方法的设置,所以你必须将一个函数名称传递给一个自定义方法来打印所有未处理异常的堆栈跟踪具体功能.我正在寻找一种方法,不必手动将函数名称传递给自定义方法,该方法打印所有未处理异常的堆栈跟踪.我希望这些自定义方法只是"监听"整个应用程序中所有未处理的异常.

http://eriwen.com/javascript/js-stack-trace/

也类似于上一个链接:

https://github.com/eriwen/javascript-stacktrace

这是上面第二个链接的基本代码,它打印了指定javascript函数的堆栈跟踪:

instrumentFunction: function (context, functionName, callback) {
    context = context || window;
    var original = context[functionName];
    context[functionName] = function instrumented() {
        callback.call(this, printStackTrace().slice(4));
        return context[functionName]._instrumented.apply(this, arguments);
    };
    context[functionName]._instrumented = original;
}

function printStackTrace(options) {
    options = options || {
        guess: true
    };
    var ex = options.e || null,
        guess = !! options.guess;
    var p = new printStackTrace.implementation(),
        result = p.run(ex);
    return (guess) ? p.guessAnonymousFunctions(result) : result;
}
Run Code Online (Sandbox Code Playgroud)

总而言之,你们都知道有什么方法可以让某些"倾听者"听取所有javascript未处理的异常,然后将它们打印到屏幕上的警告框中吗?

谢谢!贾森

javascript

97
推荐指数
5
解决办法
6万
查看次数

jquery中的wait()或sleep()函数?

我想添加一个类,等待2秒并添加另一个类.

.addClass("load").wait(2sec).addClass("done");
Run Code Online (Sandbox Code Playgroud)

有什么办法吗?

jquery

93
推荐指数
4
解决办法
48万
查看次数

在bootstrap模式中将textarea宽度设置为100%

正在尝试所有可能的方法,但从未成功:

    <div style="float: right">
        <button type="button" value="Decline" class="btn btn-danger" data-toggle="modal" data-target="#declineModal">Decline</button>
    </div>

    <!-- Modal -->
    <div class="modal fade" id="declineModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel">Comment</h4>
                    </div>
                    <div class="modal-body">
                        <textarea class="form-control col-xs-12"></textarea>
                    </div>
                    <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-danger">Decline</button>
                </div>
            </div>
        </div>
    </div> 
Run Code Online (Sandbox Code Playgroud)

如何使modal-body div中的textarea覆盖所有可用空间=宽度100%?

html5 textarea css3 twitter-bootstrap bootstrap-modal

57
推荐指数
4
解决办法
10万
查看次数

如何更改bootstrap中form-control的popover中必填字段的默认消息?

 <form class="form-asd" role="form">
    <h2 class="form-signin-heading">login</h2><hr />
    <label class="control-label"  for="username">Username</label>
    <input class="form-control" type="email"  required="" placeholder="username"data-error="enter valid username"></input>
    <label class="control-label"  for="username">password</label>
    <input class="form-control" type="password"  required=" " placeholder="Password"></input>
    <label class="checkbox"></label>
    <button class="btn btn-lg btn-primary " type="submit">submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)

我们如何更改require字段popover的默认消息"请填写此字段"至"请输入用户名"

html5 css3 twitter-bootstrap

55
推荐指数
3
解决办法
13万
查看次数

在JSfiddle中添加图像

我想创建一个小提琴,我必须添加一个图像..(作为div的背景图像)

我尝试在左边使用添加资源,但它不起作用,我也试图在我的文件夹结构中给出完整的图像路径,但这也没有用.

有谁知道怎么做?

html javascript jsfiddle

50
推荐指数
3
解决办法
3万
查看次数

如何确定jQuery对象是否延迟?

如果我有一个函数,有时会返回一个延迟对象,但有时会返回一个非延迟对象.我怎么知道它是哪一个?

javascript jquery jquery-deferred

48
推荐指数
2
解决办法
9602
查看次数

表单提交前的Bootstrap Modal

我是Modals的新手,我有一个表格,当用户点击提交时,它会显示一个模态确认用户是否想要提交,该模式还包含来自表单字段的用户输入.我搜索了整个互联网,但找不到合适的我的需求.我只看到他们将click事件标记为在链接上打开模态.我有一个输入类型提交.你能举出例子或想法吗?谢谢!这是我的样本表格.

<form role="form" id="formfield" action="inc/Controller/OperatorController.php" method="post"  enctype="multipart/form-data" onsubmit="return validateForm();">
<input type="hidden" name="action" value="add_form" /> 

       <div class="form-group">
         <label>Last Name</label><span class="label label-danger">*required</span>
         <input class="form-control" placeholder="Enter Last Name" name="lastname" id="lastname">
       </div>

        <div class="form-group">
          <label>First Name</label><span class="label label-danger">*required</span>
          <input class="form-control" placeholder="Enter First Name" name="firstname" id="firstname">
       </div>

  <input type="submit" name="btn" value="Submit" id="submitBtn" class="btn btn-default" data-confirm="Are you sure you want to delete?"/>
  <input type="button" name="btn" value="Reset" onclick="window.location='fillup.php'" class="btn btn-default" data-modal-type="confirm"/>
</form>
Run Code Online (Sandbox Code Playgroud)

javascript jquery modal-dialog twitter-bootstrap

34
推荐指数
1
解决办法
10万
查看次数

在Bootstrap 3中,如何更改垂直行之间的距离?

我有两行a和b,我认为垂直两行之间的距离太小.

我想让距离更大,我知道我可以通过col-md-offset来改变水平距离 - *.但是如何改变垂直距离?

   <div class="row" id="a">
      <img> ... </img>
    <div>
    <div class="row" id="b">
      <button>..</button>
    <div>
Run Code Online (Sandbox Code Playgroud)

现在我的解决方案是插入h1的标签,我认为它不优雅.

   <div class="row" id="a">
      <img> ... </img>
    <div>
    <h1></h1>
    <div class="row" id="b">
      <button>..</button>
    <div>
Run Code Online (Sandbox Code Playgroud)

它有更优雅的解决方案吗?

html css twitter-bootstrap twitter-bootstrap-3

31
推荐指数
4
解决办法
12万
查看次数

在typescript中引用javascript文件

我想在打字稿文件中使用javascript函数.如何在typescript文件中引用包含该函数的javascript文件?

我试过了

<reference path="../libs/myjsfile.js" />
Run Code Online (Sandbox Code Playgroud)

这会在构建时带来错误: Cannot resolve referenced file: ../libs/myjsfile.js

javascript reference typescript

31
推荐指数
2
解决办法
4万
查看次数

bootstrap按钮:拉伸以填充其容器空间

我正在使用引导按钮,我想拉伸中间的下拉按钮以填充工具栏空间的其余部分.

在此输入图像描述

HTML(缩短代码):

<div class="gallery-toolbar">
    <ul style="padding:0">
   <li><a>Back</a></li>

   <li id="gallery_title">
   <div class="btn-group">
     <a class="btn btn-default"><?php echo $gallery->title ?></a>
     <a class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
     <ul class="dropdown-menu">some php</ul>
   </div></li>

  <li><a>Slideshow</a></li>
Run Code Online (Sandbox Code Playgroud)

CSS:

.gallery-toolbar li { list-style:none; display: inline }
.gallery-toolbar li:last-child { float:right }
#gallery-title { ?? }
Run Code Online (Sandbox Code Playgroud)

我尝试过"btn-group-jastified"这个课,但它根本没用.

有任何想法吗?

css stretching twitter-bootstrap

30
推荐指数
1
解决办法
5万
查看次数