在主页(如index.html)html代码中加入以下javascript代码,但不要加在.content div中。
<script>
window.addEventListener('push', function () {
var scriptsList = document.querySelectorAll('script.js-custom');
for (var i = 0; i < scriptsList.length; ++i) {
eval(scriptsList[i].innerHTML);
}
});
</script>
<div class="content">
<script class="js-custom">
alert('I was executed!');
</script>
</div>