在博客园中执行本身的脚本

在页脚Html代码中加入:css

<!-- 运行页面上的自定义脚本 -->
<style type="text/css">
textarea[title=js]
{ 
    display: none;
}
</style>
<script>
$(function()
{
    $('textarea[title=js]').each(function(){window.eval($(this).text())});
});
</script>

代码简单,你懂得,我就不说啥了。html

在界面上添加对应的元素,测试

<textarea title="js">function t1(v)
{
var dt=new Date();
var str=dt.getHours()+":"+dt.getMinutes()+":"+dt.getSeconds();
str="---------- ["+str+"] t1执行日志 : "+v+" -----------";
  console.log(str);
$('#res').html(str);
}
</textarea>
<div id="res" style="color: red; font-weight: bold;"> 

this

 

 

点击按钮测试spa

 

 转自:日志

https://www.cnblogs.com/mq0036/p/10348687.htmlcode

相关文章
相关标签/搜索