Code Monkey home page Code Monkey logo

issues-solutions's People

Contributors

superyunlongzhang avatar

Watchers

 avatar  avatar

issues-solutions's Issues

字体文件跨域的解决办法

1、apache
首先编辑httpd.conf

找到这行

#LoadModule headers_module modules/mod_headers.so
把#注释符去掉
LoadModule headers_module modules/mod_headers.so
目的是开启apache头信息自定义模块
然后在独立资源域名的虚拟主机添加一行
Header set Access-Control-Allow-Origin *
意思是对这个域名的资源进行访问时,添加一个头信息
重启apache
To add the CORS authorization to the header using Apache, simply add the following line inside either the , , or sections of your server config (usually located in a *.conf file, such as httpd.conf or apache.conf), or within a .htaccess file:

Header set Access-Control-Allow-Origin "*"

参考链接
https://www.w3.org/TR/cors/#access-control-allow-origin-response-header
https://gist.github.com/hoandang/8066175
https://gist.github.com/Plou/5809547
http://enable-cors.org/server_apache.html

2、nginx

处理这种跨域,只要设置Access-Control-Allow-Origin,允许目标域名访问就可以了,Access-Control-Allow-Origin是HTML5新增的一个特性,在资源类的域名下做如下配置(nginx的配置,apache相似处理)​

location ~ ..(eot|ttf|ttc|otf|eot|woff|woff2|svg)(.) {
add_header Access-Control-Allow-Origin http://www.yuehetong.com或(*);

}

$.serialize()

$.serialize()方法会将空格替换成 + 号 ,即调用encodeURIComponent对字符串进行编码,
解码后需要对+号特殊处理,先替换+号成空格 ,然后再调用decodeURIComponent方法解码

$('body').scrollTop()兼容问题

在火狐上只能通过html元素来获取和设定页面滚动高度,而在谷歌上反之只能用body元素来获取和设定。
若要设定动画,可以通过$('html,body').animate({scrollTop:'value'}),$(document)无法设定动画;
若要获取滚动高度,通过$(document).scrollTop()来获取

移动端点击闪烁

body添加属性 -webkit-tap-highlight-color: transparent;

ios系统移动端回弹效果 -webkit-overflow-scrolling: touch;

中文输入法的问题

监听input、textarea等的input,compositionstart,compositionend事件
//基于jquery的写法
var cpLock = false;
$(obj).on({
input:function(){
if(!cpLock){
//do something
}
},
compositionstart:function(){
cpLock = true;
},
compositionend:function(){
cpLock = false;
//do something
}

})

判断script或link标签是否加在完成

var obj = link || script;
if(obj.readyState){
//IE
obj.onreadaystatechange = function(){if(/complete|loaded/.test(obj.readyState)){
//do something
}}
}else{
obj.onload = function(){
//do something
}
}

2017-09-09

float布局,容器不固定宽度,在windows的chrome中滚动条会占用页面宽度,导致页面错乱

textarea自动长高 autosize.js

监测页面的可见事件

function openApp(options){
var baseScheme = '####://' + options.route + '?';
var createScheme = function(_options){
_options = _options || {};
var urlScheme = baseScheme;
for(var item in _options){
urlScheme = urlScheme + item + '=' + _options[item] + '&';
}
urlScheme = urlScheme.substring(0,urlScheme.length - 1);
return urlScheme;
};
window.location.href = createScheme(options.query);
//若跳转不成功,两秒后跳到下载页
var timeout = setTimeout(function(){
window.location.href = '#link';
},2000);
document.addEventListener('visibilityChange', function() {
clearTimeout(timeout)
}, false);
}

//移动端开发在app中代开链接

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.