Skip to content

Instantly share code, notes, and snippets.

@janily
janily / iframe
Created May 27, 2013 08:06
iframe
HTML代码:
<iframe id="testIframe" frameborder="0" scrolling="no" src="iframe-page-no-fresh.html" width="100%" height="120"></iframe>
JS代码:
//高度自适应
var iframe = document.getElementById("testIframe");
var iframeHeight = function() {
var hash = window.location.hash.slice(1), h;
if (hash && /height=/.test(hash)) {
h = hash.replace("height=", "");
iframe.height = h;
@janily
janily / playerBox
Created May 27, 2013 08:09
music player
(function(){
XMLHttpData();
})();
//---------------------------------------------------【AJAX载入歌曲信息】
function XMLHttpData(){
var xmlhttp,
song;
loadXMLDoc("songData.json");
@janily
janily / play
Created May 27, 2013 12:12
jquery play
(function($){
// Settings
var repeat = localStorage.repeat || 0,
shuffle = localStorage.shuffle || 'false',
continous = true,
autoplay = false,
playlist = [
{
title: '光辉岁月',
artist: '光辉岁月',
@janily
janily / imgcover
Created June 21, 2013 02:55
背景图片自适应
$(function(){
$("body").append("<div id='main_bg'/>");
$("#main_bg").append("<img src='bg.jpg' id='bigpic'>");
cover();
$(window).resize(function(){ //浏览器窗口变化
cover();
});
});
function cover(){
var win_width = $(window).width();
/*
* Read more here:
* http://front-back.com/a-cool-css-spinner-with-less-variables
*/
/*
* This is a nice full CSS3 loader made with LESS
* so you'll have to compile it into CSS to make it work in your project
* See the doc on the LESS website : http://lesscss.org/
*/
RewriteEngine On
RewriteRule ^/?Resource/(.*)$ /$1 [L]
RewriteRule ^$ /home [redirect]
RewriteRule ^([a-zA-Z]+)/?([a-zA-Z0-9/]*)$ /app.php?page=$1&query=$2 [L]
[
{
name:"HTML5",
uri:"http://www.w3.org/TR/html5/single-page.html",
category:"markup"
},
{
name:"HTML 5.1",
uri:"http://www.w3.org/TR/html51/single-page.html",
category:"markup"
@janily
janily / jsmobile
Last active December 19, 2015 19:38
判断移动设备加载样式
// 判断是否为移动端运行环境
// wukong.name 20130716
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
if(window.location.href.indexOf("?mobile")<0){
try{
@janily
janily / gist:6067978
Created July 24, 2013 03:59
scroll page
//七行代码实现层随屏幕滚动
$(function(){
var chatbox = $(".chatbox").offset().top;
$(window).scroll(function (){
var offsetTop = chatbox + $(window).scrollTop() +"px";
$(".chatbox").animate({top : offsetTop },{ duration:800 , queue:false });
});
})
//鼠标经过图片,其他图片渐隐效果
$(function(){
@janily
janily / img auto
Created July 24, 2013 09:21
未知图片宽高垂直居中
<div class="imgBox">
<img src="" />
</div>
.imgBox {
display:table-cell;width:200px;height:200px;vertical-align:middle;text-align:center;
*float:left;*font-family:simsun;*font-size:200px;*line-height:1;
border:1px solid #000000;
}
.imgBox img {