最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I use toastr? - Stack Overflow

programmeradmin2浏览0评论

I like the idea of what I can do with toastr, but I can't seem to get it to work.

From the official page...

(1) Link to toastr.css
(2) Link to toastr.js
(3) Use toastr to display a toast for info, success, warning or error
To install toastr, run the following mand in the Package Manager Console
Install-Package toastr

I downloaded the mand-line version of NuGet and typed in install toastr and it successfully installed, (although I have no idea what it actually did.......) then, in my page, test.php, I have the following code:

<html>
<head>
<link rel="stylesheet" href="/toastr.css">
<script type="text/javascript" src="/toastr.js"></script>
<script type="text/javascript" src=".0.3/jquery.min.js"></script>
<script type="text/javascript" src=".1.1/js/bootstrap.min.js"></script>
</head>

<body>
toastr.info('Hey - it works!');
</body>

The website itself says this is incredibly simple....

// Display an info toast with no title

toastr.info('Are you the 6 fingered man?')

but when I execute the page, all I see is literally:

toastr.info('Hey - it works!');

What am I doing wrong?

I like the idea of what I can do with toastr, but I can't seem to get it to work.

From the official page...

(1) Link to toastr.css
(2) Link to toastr.js
(3) Use toastr to display a toast for info, success, warning or error
To install toastr, run the following mand in the Package Manager Console
Install-Package toastr

I downloaded the mand-line version of NuGet and typed in install toastr and it successfully installed, (although I have no idea what it actually did.......) then, in my page, test.php, I have the following code:

<html>
<head>
<link rel="stylesheet" href="/toastr.css">
<script type="text/javascript" src="/toastr.js"></script>
<script type="text/javascript" src="https://ajax.googleapis./ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript" src="https://netdna.bootstrapcdn./bootstrap/3.1.1/js/bootstrap.min.js"></script>
</head>

<body>
toastr.info('Hey - it works!');
</body>

The website itself says this is incredibly simple....

// Display an info toast with no title

toastr.info('Are you the 6 fingered man?')

but when I execute the page, all I see is literally:

toastr.info('Hey - it works!');

What am I doing wrong?

Share Improve this question asked Oct 9, 2014 at 22:33 lordterrinlordterrin 1712 gold badges2 silver badges10 bronze badges 1
  • 4 You might want to review a rudimentary javascript tutorial – Sinkingpoint Commented Oct 9, 2014 at 22:35
Add a ment  | 

1 Answer 1

Reset to default 2

You could just add your script tag before your close body tag, and also, use it in a valida javascript scope.

.. all html page

<script>

    $(document).ready(function() {

        // show when page load
        toastr.info('Hey - it works!');

    });

</script>

</body>
</html>

You also have other methods,

// for success - green box
toastr.success('Success messages');

// for errors - red box
toastr.error('errors messages');

// for warning - orange box
toastr.warning('warning messages');

// for info - blue box
toastr.info('info messages');
发布评论

评论列表(0)

  1. 暂无评论