はい、私は22may(1週間前)に同じ質問に対する回答がありますが、私は同じ解決策を試しました。実際の "呼び出し"の前に指定されていますtoastrスクリプト、私は両方で試したことがあります:と=しかし、私は問題を解決することはできません。Toastrはオプションに従いません
最初のコードは、「クッキーが設定されているかどうかを確認し、そうでなければ、トーストを表示してクッキーを設定する」スクリプトを含むページ全体です。
"オプション"を除いて、これは機能します。
$(function() {toastr.option.progressBar= true;
toastr["error"]("We use Cookies!","Cookies!")
});
: それは、画面上の2 toastr
<!DOCTYPE html><html><head><meta charset=utf-8>
<link href="https://my.site.se/js/toastr.css" rel="stylesheet" type="text/css" />
<script src= "https://my.site.se/js/jquery-3.2.1.js"></script>
<script src="https://my.site.se/js/toastr.js"></script>
<!-- createCookie funktion -->
<script>
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
</script>
<script>
<!-- see if the i agree cookie is set, else send them to the info page -->
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
toastr.options = {
"closeButton": true,
"debug": false,
"newestOnTop": false,
"progressBar": true,
"positionClass": "toast-top-left",
"preventDuplicates": false,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
$(function() {
toastr.options.closeButton: true;
toastr.options.progressBar=true;
toastr["error"]("We use Cookies!","Cookies!")
});
$(function() {toastr["info"]("We have now created a cookie that prevents this information from being displayed again, unless you remove the cookie of course\n Read the terms page for more info\n To delete ALL your cookies, press the delete cookies button!")});
}
</script>
</Head>
<body>
<script>
readCookie('acceptterms');
</script>
<script>
createCookie('acceptterms','yesIdo',3650);
</script>
コードは、私はそれがすべてでは動作しません体内に入れた場合、私も試してみた、頭の中で表示されますまた、私はそれが目を設定するために一生懸命だ、なぜ私は理解できない体で
toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": true, "positionClass": "toast-top-left", "preventDuplicates": false, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" }
... そして、私は今でも覚えていないことができるいくつかの.. を設定しようとしましたEオプション...
オプションは、スクリプト自体に変更することができれば、それは容易になるだろうが、私はそこに見つけることができないいくつかがあります。..