Skip to content

Instantly share code, notes, and snippets.

View foru17's full-sized avatar
🎯
Focusing

Luo Lei foru17

🎯
Focusing
View GitHub Profile
@foru17
foru17 / bindaclick.js
Created April 29, 2014 02:47
统计绑定页面a链接的一个兼容ajax的方法
$(document).on('click','a',function(e){
var _this = $(e.target);
if(_this.attr('href') != undefined && $(_this).attr('href')!='javascript:void(0);'){
try{
window.external.MyInvoke();
}
catch(e){
}
}
})
@foru17
foru17 / WPressset.php
Created May 7, 2014 13:09
Wordrpess中自定义参数和处理空值
<?php
$guideWord=get_post_meta($post->ID, "guide_word_value", $single = true);
$buttonUrl=get_post_meta($post->ID, "custom_button_url_value", $single = true);
?>
<?php if (!empty ($guideWord)) {echo $guideWord ;} else {echo "If you like it, please rate us" ;}
?>
<html>
<head>
<title>...</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
</head>
</html>
<a href="signin.php" rel="nofollow">sign in</a>
@foru17
foru17 / phpbase1.php
Created June 5, 2014 08:36
php 的基础 if else 兼容语法
<?php if ($username == 'sally'): ?>
<h3>Hi Sally</h3>
<?php elseif ($username == 'joe'): ?>
<h3>Hi Joe</h3>
<?php else: ?>
@foru17
foru17 / AnimatedToTop.html
Created June 5, 2014 14:03
原生JS返回顶部动画
<div it="gotop"> </div>
<script>
backTop = function (btnId){
var btn = document.getElementById(btnId);
var d = document.documentElement;
var b = document.body;
window.onscroll = btnDisplay;
btn.onclick = function (){
btn.style.display = "none";
window.onscroll = null;
@foru17
foru17 / markdownvideo.html
Created June 7, 2014 06:17
在Markdown中添加视频方法
<video id="video" controls="" preload="none" poster="http://media.w3.org/2010/05/sintel/poster.png">
<source id="mp4" src="http://media.w3.org/2010/05/sintel/trailer.mp4" type="video/mp4">
<source id="webm" src="http://media.w3.org/2010/05/sintel/trailer.webm" type="video/webm">
<source id="ogv" src="http://media.w3.org/2010/05/sintel/trailer.ogv" type="video/ogg">
<p>Your user agent does not support the HTML5 Video element.</p>
</video>
@foru17
foru17 / getHttpRequest.js
Created June 10, 2014 07:21
JavaScript 发送 GET请求
function httpGet(theUrl)
{
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false );
xmlHttp.send( null );
return xmlHttp.responseText;
}
@foru17
foru17 / inserthtml.js
Last active August 29, 2015 14:02
js创建和添加元素
theParent = document.getElementById("theParent");
theKid = document.createElement("div");
theKid.innerHTML = 'Are we there yet?';
// append theKid to the end of theParent
theParent.appendChild(theKid);
// prepend theKid to the beginning of theParent
theParent.insertBefore(theKid, theParent.firstChild);
@foru17
foru17 / base64bgimg.html
Last active August 29, 2015 14:02
在项目中使用Base64 图片为背景
/*
在线转换 http://dopiaza.org/tools/datauri/index.php
比较转换后字符大小 http://bytesizematters.com/
*/
<style>
.dot {
background-image: url(data:image/gif;base64,R0lGODlhBAABAIABAMLBwfLx8SH5BAEAAAEALAAAAAAEAAEAAAICRF4AOw==);
*background-image: url(http://www.zhangxinxu.com/wordpress/wp-content/themes/default/images/zxx_dotted.gif); // IE6~IE7
}
@foru17
foru17 / textmask.html
Created June 12, 2014 14:01
给文字创造一个渐隐的图层
<style>
.intro{
display: block;
height: 26px;
line-height: 26px;
width: 300px;
overflow: hidden;
position: relative;
}