4年前 (2015-05-19)  web相关 系统运维 |   94 条评论  74 
百度已收录 | 文章评分 1 次,平均分 5.0

持续整理更新一些建站时使用的代码

页面跳转代码

<script language='javascript'>document.location = '地址'</script>

音乐播放器代码

<audio width="300" height="30" style="margin:10px 5px 15px;; auto; top:55;right: 0; bottom: 10; left: 0;" controls="controls" autoplay="autoplay" name="media" src="http://7xj28j.com1.z0.glb.clouddn.com/x10908451.mp3"></audio>

图片超链接代码

<a href="链接地址" /><img src="图片地址" /></a>

图片超链接在新窗口打开代码

<A href="链接地址" target=_blank><IMG src=" 图片地址" border=0></A>
文字超链接代码

&lt;a href="链接地址" rel="nofollow" target="_blank"&gt;文字&lt;/a&gt;

计时器代码

&lt;SPAN id=span_dt_dt&gt;&lt;/SPAN&gt;
 &lt;SCRIPT language=javascript&gt;
 function show_date_time() {
 window.setTimeout("show_date_time()", 1000);
 BirthDay = new Date("4/18/2015 11:30:00");
 today = new Date();
 timeold = (today.getTime() - BirthDay.getTime());
 sectimeold = timeold / 1000
 secondsold = Math.floor(sectimeold);
 msPerDay = 24 * 60 * 60 * 1000
 e_daysold = timeold / msPerDay
 daysold = Math.floor(e_daysold);
 e_hrsold = (e_daysold - daysold) * 24;
 hrsold = Math.floor(e_hrsold);
 e_minsold = (e_hrsold - hrsold) * 60;
 minsold = Math.floor((e_hrsold - hrsold) * 60);
 seconds = Math.floor((e_minsold - minsold) * 60);
 span_dt_dt.innerHTML = daysold + "天" + hrsold + "小时" + minsold + "分" + seconds + "秒";
 }
 show_date_time();
&lt;/SCRIPT&gt;

title彩蛋代码:

$(function(){
 var RelTitle = document.title;
 var hidden, visibilityChange; 
 if (typeof document.hidden !== "undefined") {
 hidden = "hidden";
 visibilityChange = "visibilitychange";
 } else if (typeof document.mozHidden !== "undefined") { // Firefox up to v17
 hidden = "mozHidden";
 visibilityChange = "mozvisibilitychange";
 } else if (typeof document.webkitHidden !== "undefined") { // Chrome up to v32, Android up to v4.4, Blackberry up to v10
 hidden = "webkitHidden";
 visibilityChange = "webkitvisibilitychange";
 }
 function handleVisibilityChange() {
 if (document[hidden]) {
 document.title = '(●––●) Hi, BigBai';
 } else {
 document.title = RelTitle;
 }
 }
 if (typeof document.addEventListener !== "undefined" || typeof document[hidden] !== "undefined") {
 document.addEventListener(visibilityChange, handleVisibilityChange, false);
 }
});

wordpress更改头像源代码

function mytheme_get_avatar($avatar) {
 $avatar = str_replace(array("www.gravatar.com","0.gravatar.com","1.gravatar.com","2.gravatar.com"),"gravatar.duoshuo.com",$avatar);
 return $avatar;
 }
 add_filter( 'get_avatar', 'mytheme_get_avatar', 10, 3 );

支付宝链接钮代码

<form accept-charset="GBK" action="https://shenghuo.alipay.com/send/payment/fill.htm" method="POST" target="_blank">
<input name="optEmail" type="hidden" value="15698880400" />
<input name="payAmount" type="hidden" value="1" />
<input name="memo" type="hidden" value="有什么想对我说的" />
<input name="title" type="hidden" value="赞助博主" />
<input name="pay" src="http://7xj28j.com1.z0.glb.clouddn.com/QQ图片20150518105152.png" type="image" value="赞助博主" />
外链播放器代码

&lt;iframe src="http://audioplm.sinaapp.com/xiamiplayer/1114507.mp3" width="430" height="200" frameborder="0" scrolling="0"&gt;&lt;/iframe&gt;

用js实现计算加载页面所用的时间

在页面Head部分加入初始时间

<script language=javascript>
var t1 = new Date().getTime();
</script>
在Body中添加如下代码

<SCRIPT LANGUAGE="JavaScript">
window.onload = function()
{
document.getElementById("TimeShow").innerHTML = "加载本页耗时 "+ (new Date().getTime()-t1) +" 毫秒";
}
</SCRIPT>
在需要显示的地方插入一个ID为TimeShow的标签即可

<div id="TimeShow"></div>

 

除特别注明外,本站所有文章均为张子豪博客(ZihaoBlog)原创,转载请注明出处来自https://www.zihao123.com/137.html

关于
93年菜鸟云主机运维。

发表评论

表情 格式

暂无评论

切换注册

登录

忘记密码 ?

您也可以使用第三方帐号快捷登录

切换登录

注册

×
订阅图标按钮