分类: 技术

  • href与src的区别

     

    SRC (Source)
    src用于置换元素[1],即使说这个元素的内容通过src的地址获得,且不受css样式限制。比如

    <script /> 
    <img /> 
    <video /> 
    <object />
    

    等。浏览器在解析到此处时会暂停所有渲染,加载直到此处内容被加载完成。
    所以建议<script>放置在页面底端。比如:

    <script src="dom1.js"></script>

    HREF (HyperText Reference)
    href 用于建立链接关系,比如

    <a>, <link>
    

    元素,浏览器在解析到此处时之道这里是个外部链接(或锚点)而并不需要加载这个链接的内容。因此页面解析不会被暂停。比如:

    <a href="#yourAnchor">Click me</a>
    
    URL (Uniform Resource Locator)
    狭义来讲,在这里url代表了CSS的一个数据类型,它指定了一个数据的链接位置。通常的用法是用url()函数。比如

    #your-element{
      background-image:url(http://placekitten.com/500/500);
    }

    There is a differentiation between src and href and they can’t be used interchangeably. We usesrc for replaced elements while href for establishing a relationship between the referencing document and an external resource.
    href (Hypertext Reference) attribute specifies the location of a Web resource thus defining a link or relationship between the current element (in case of anchor a) or current document (in case of link) and the destination anchor or resource defined by this attribute. When we write:
    The browser understands that this resource is a stylesheet and the processing parsing of the page isnot paused (rendering might be paused since the browser needs the style rules to paint and render the page). It is not similar to dumping the contents of the css file inside the style tag. (Hence is is advisable to use link rather than @import for attaching stylesheets to your html document.)
    src (Source) attribute just embeds the resource in the current document at the location of the element’s definition. For eg. When the browser finds

    The loading and processing of the page is paused until this the browser fetches, compiles and executes the file. It is similar to dumping the contents of the js file inside the script tag. Similar is the case with img tag. It is an empty tag and the content, that should come inside it, is defined by the src attribute. The browser pauses the loading until it fetches and loads the image. [so is the case with iframe]

    引用
    http://stackoverflow.com/questions/3395359/difference-between-src-and-href

  • 检测回文字中国古代回文诗

    首先什么是回文字?
    回文字就像 eye 和 12321 77888877之类对称的 人美赏美人
    因为回文字左右调换后,是相同的,那么就判断是否相等,相等则是回文字,不相等则否。
    比如 以下运行结果
    palindrome(“eye”) 应该返回一个布尔值
    palindrome(“eye”) 应该返回 true.
    palindrome(“race car”) 应该返回 true.
    palindrome(“not a palindrome”) 应该返回 false.
    palindrome(“A man, a plan, a canal. Panama”) 应该返回 true.
    palindrome(“never odd or even”) 应该返回 true.
    palindrome(“nope”) 应该返回 false.
    palindrome(“almostomla”) 应该返回 false.
    palindrome(“My age is 0, 0 si ega ym.”) 应该返回 true.
    palindrome(“1 eye for of 1 eye.”) 应该返回 false.
    palindrome(“0_0 (: /-\ 🙂 0-0”) 应该返回 true.


  • wordpress 多语言国际化

     

      1. 在主题文件functions.php中加入

        function is_lang($lang) {

           return (ICL_LANGUAGE_CODE == $lang) ? true : false;

        }

     

    1. 2

      在相应位置处调用方式:

      <?php if (is_lang(‘en’)) : ?>

      //英文状态下显示内容,is_lang()里面填写语言标识fr(法语),de(德语)等等···

      <?php else :?>

      //非英文下显示内容

      <?php endif;?>

       
  • Appcan使用遇到问题和方法整理

    1、抽屉页面效果注意点
    退回上一页(抽屉里面的返回上一页)
    <div class=”umw4 ub ub-ac ub-pc” ontouchstart=”zy_touch(‘btn-act’)” onclick=”closeWin();”>
    <div class=”t-btn-a1 ub-img uwh-tBtn”></div>
    </div>
    抽屉页面(修改完毕后,只能放在连接内部有用)
    Ⅰ. right.html(首页)
    Root要改掉 window.uexOnload = function(type){
    if (!type) {
    //uescript(‘root’,’openPover()’);
    uescript(‘right_drawer’,’openPover()’);
    zy_con(“content”, “right_content.html”, 0, $$(“header”).offsetHeight);
    var plat = uexWidgetOne.getPlatform();
    Ⅱ. right_drawer.html(可以预览的抽屉效果,内容是清除条件和确认。)
    Ⅲ. right_content.html(right的content内容)
    Ⅳ. Filer.html(抽屉内的选项)
    当出现抽屉里面的效果有滚动条的时候,变header为
    <!DOCTYPE html>
    <html class=”um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px”>
    <head>
    <title></title>
    <meta charset=”utf-8″>
    <meta name=”viewport” content=”target-densitydpi=device-dpi,initial-scale=1″>
    <link rel=”stylesheet” href=”css/ui-on.css”>
    2、一般页面返回上一页(系统默认)
    <!–按钮开始–>
    <div class=”ub btn btn-l”>
    <div class=”btn-al”>
    </div>
    <div class=”btn-ac ub ub-ac ulim uinn1″ onmousedown=”zy_touch(”);” ontouchstart=”zy_touch(”)” onclick=”winClose();”>
    返回
    </div>
    <div class=”btn-ar”>
    </div>
    </div>
    3、修改页面内的元素名字,调取数据,可以直接F5预览,修改样式图片之类的,需要重新加载预览
    4、鼠标按下去的效果用
    <div class=”umw4 ub ub-ac ub-pc” ontouchstart=”zy_touch(‘btn-act’)” onmousedown=”zy_touch(‘btn-act’);” onclick=”winClose();”>
    <div class=”t-btn-a1 ub-img uwh-tBtn”></div>
    </div>
    加class名,可以修改在按下去瞬间的样式,可以改变颜色和大小等。
    5、get获取json值
    zy_init();
    var pageSize = 10;
    var pageLen = 1;
    var isLoading = false;
    window.uexOnload = function(type){
    if (!type) {
    sortList();
    // uexWindow.setBounce(“1”);
    setPageBounce(1, function(){
    //刷新
    pageLen = 1;
    sortList();
    }, function(){ //加载更多
    pageLen++;
    sortList();
    // alert(pageLen);
    });
    }
    }

    function sortList(){
    $toast(‘数据加载中…’);
    $.getJSON(‘http://10.1.97.139:18080/10000000/public/BDP/bdpservice?func=listAllProjects&body={“arg0″:”UN0366″,”arg1″:’ + pageSize + ‘,”arg2″:’ + pageLen + ‘,”arg3″:0}’, function(data){
    $closeToast();
    //$.getJSON(http://10.1.97.139:18080/10000000/public/PBD/”)
    // $.getJSON(‘http://10.1.2.206:9090/xxxx/xxxx/default/soap?loginName=040021genglm&pass=ss’,function(data){
    // alert(data.netLoginInfo.loginName);
    isLoading = false;
    resetBV(0);
    resetBV(1);
    if (data.status == ‘0’ && data.data && data.data.projectBasicInfoList.length) {
    $closeToast();
    var dataLen = data.data.projectBasicInfoList;
    var tmpl = ‘<div class=”ub t-bla ulev0 ubb b-gra uinn5″ ontouchstart=”zy_touch(\’\’)” onclick=”openGoods(event);”>’ +
    ‘<div class=” b-gra ub-f1 uc-l1″>’ +
    ‘<div class=”ub ub-ver t-bla”>’ +
    ‘<div class=”b-gra uc-t1 umar-t”>${serialno}</div>’ +
    ‘<div class=”b-gra “>${money}3323</div>’ +
    ‘</div>’ +
    ‘</div>’ +
    ‘<div class=”ub-f1 ulev0″>’ +
    ‘ <div class=”ub ub-ver”>’ +
    ‘ <div class=” b-gra uc-t1″> U${countryCode}</div>’ +
    ‘<div class=” b-gra ulev0 t-orgs”>${projectWorkUserId}</div>’ +
    ‘<div class=” uc-b1 ulev-1″>${style}OA ${deathline}56天 USD</div>’ +
    ‘</div>’ +
    ‘</div>’ +
    ‘<div class=”ub-f1 uc-r1 ulev0″>’ +
    ‘<div class=”ub ub-ver t-bla”>’ +
    ‘<div class=” b-gra uc-t1″>部分收匯</div>’ +
    ‘<div class=” b-gra ulev-1 “>${statusDate}</div>’ +
    ‘<div class=” uc-b1 ulev-1″> ${projectWorkcorpId}</div>’ +
    ‘</div>’ +
    ‘</div>’ +
    ‘</div>’
    var s = zy_tmpl(tmpl, dataLen, zy_tmpl_count(dataLen));
    var d = document.createElement(‘DIV’);
    d.innerHTML = s;
    $$(‘sortList’).appendChild(d);
    }
    else {
    if (pageLen == 1) {
    $$(‘sortList’).innerHTML = ‘<div class=”ub ub-ac ub-pc uinn”>暂时没有数据</div>’
    }
    else {
    $toast(‘没有更多数据’, 2000);
    }
    }
    });
    }

    function toFront(){
    uexWidnow.bringToFront();
    }

    function openGoods(e){
    if (isPhone && e.type == ‘click’)
    return;
    openNewWin(‘r_content’, ‘r_content.html’);
    }
    Post取值
    function List(){
    var tmpl;
    $toast(“正在加载中”);
    //浏览器http协议缓过来的关键字
    var j=[
    {‘key’:’questiontitle’,’type’:’0′,’value’:$$(“KeyWord”).value},
    {‘key’:’currentPage’,’type’:’0′,’value’:pageLen},
    {‘key’:’pageSize’,’type’:’0′,’value’:15}
    ];
    $.getJSON(Lurl,function(data){
    $closeToast();
    isLoading = false;
    resetBV(0);resetBV(1);
    if (data.type == ‘0’ && data.data.items&&data.data.items.length){
    var dataLen = data.data.items;
    for(var i=0;i<dataLen.length;i++){
    tmpl +='<ul ontouchstart=”zy_touch(\’btn-act\’)” onmousedown=”zy_touch(\’btn-act\’)” onclick=”openDetail(\”+dataLen[i].questionid+’\’)” class=”uc-t ubb ub b-gra t-bla ub-ac lis”>’
    +'<li class=”ub-f1 ut-s”>’+dataLen[i].questiontitle+'</li>’
    +'<li class=”tx-r t-dgra ulev-1″>’+dataLen[i].state+'</li>’
    +'<li class=”listIcon lis-sw ub-img”></li>’
    +'</ul>’
    }
    if(pageLen==1){
    $$(“content0″).innerHTML=tmpl;
    }else{
    var child = document.createElement(‘div’);
    child.innerHTML = tmpl;
    $$(‘content0’).appendChild(child);
    }
    }else{
    if(data.data.pageCount==0){
    $$(‘content0’).innerHTML = ‘<div class=”ub ub-ac ub-pc uinn”>暂时没有数据</div>’
    }else{
    $toast(“没有更多数据”,2000)
    }
    }
    },’json’,function(e){
    alert(“输入异常”);
    },’POST’,j)}
    6、应用生成地址D:\appcan\AppCanStudioEnterprise\Mobile-Applications
    7、Svn导入文件要有.project dssam10013 打包才能成功
    设置搜索引擎 安卓 sdksuit_3.0_0820_01
    8、产品服务代码 列表-列表-详情
    ①function openDetails(i){
    var Arr=[‘短期出口信用保险’,’中长期出口信用保险’,’海外投资/租赁保险’,’国内贸易信用保险’,’资信服务’,’担保’,’信保融资’,’理赔服务’]
    setLocVal(‘pName’,JSON.stringify(Arr[i]));
    setLocVal(‘pNo’,JSON.stringify(i)); //传值
    openNewWin(‘adCon_list’, ‘adCon_list.html’);
    }
    ②列表页面
    var hNo = JSON.parse(getLocVal(“pNo”));//获得传值
    function openDetails(i){
    var ArrNo=[‘du’,’zh’,’h’,’g’,’z’,’d’,’x’,’l’];
    //中小企业综合险无 短期出口信用保险 出口买方信贷保险无 中长期出口信用保险
    var ArrTit=[
    [‘index’,’zhbx’,’tdmfbx’,’tdhtbx’,’mfwybx’,’ckxybx-yx-bxd’,’ckxybx-fft-bxd’],
    [‘index’,’ckmfxdbx’,’ckmfxdbx’,’zrzbx’],
    [‘index’,’hwtz-gq-bx’,’hwtz-zq-bx’,’hwzlbx’],
    [‘index’],
    [”],
    [‘index’],
    [”],
    [‘index’,’dxal’,’ywdy’]
    ];
    if(hNo==4||hNo==6){
    alert(“信保融资为空和资信服务为空”);
    return “信保融资为空和资信服务为空”;
    }
    //setLocVal(‘href’,JSON.stringify(‘http://10.1.97.139:9090/dssam10007/public/product/’+ArrNo[hNo]+’_’+e));
    setLocVal(‘href’,JSON.stringify(‘http://127.0.0.1:8087/xxx/xxx/product/’+ArrNo[hNo]+’_’+ArrTit[hNo][i]));
    openNewWin(‘adCon_detail’, ‘adCon_detail.html’);
    }
    ③详情页
    var liPath = JSON.parse(getLocVal(“href”)); //获得传值
    function sortList(){
    $$(‘Info’).innerHTML=””;
    $toast(‘数据加载中…’);
    $.getJSON(liPath, function(data){
    if (data!=0) {
    $closeToast();
    tmpl = ‘<div class=”ubb b-gra ub uinn3″>’
    +'<div class=”t-org ulev-app2″>${title}</div>’
    +'</div>’
    +'<div class=”uinnh1 t-gra1 ulev-app2″>’
    +'<span>${text}</span>’
    +'</div>’;
    var s = zy_tmpl(tmpl, data, zy_tmpl_count(data));
    $$(‘Info’).innerHTML=s;
    }
    else {
    $toast(‘无数据’);
    }
    });
    }
    9、传值
    setLocVal(‘path’,JSON.stringify(e)); 设置传值 变成JSON字符串 双引号
    var liPath = JSON.parse(getLocVal(“path”)); 获取传值 变成对象
    10、省略class
    Ub ut-s
    11、附件下载常用代码
    function Down(e){
    var Durl=’http://10.1.97.139:9090/dssam10007/public/BMsg/OpenSoldsPdfWS?path=’;
    //Console.Log(Durl+e);
    alert(Durl+e);
    downloadFile(Durl,”1111.pdf”);
    }

    12、Zy-tmpl.js 截取字段

    var ar=c.split(‘.’);
    var res=d;
    for(var key in ar)
    if(ar[key].match(/.*sub:.*/)){
    var ts = ar[key];
    var tsar = ts.split(“:”);

    if(tsar.length > 1){
    var num = tsar[1];
    var numar = num.split(‘-‘);
    if(numar.length > 1){
    res = res.substring(numar[0],numar[1]);
    }else if(numar.length == 1){
    res = res.substring(numar[0]);
    }
    }
    }else{
    res=res[ar[key]];
    }
    ${workDate.sub:0-10} 0到10索引值
    ${workDate.sub:11} 索引值11之后
    13、IOS android取值
    var sVal=encodeURIComponent($$(“search”).value);
    if(!isAndroid){
    var sVal=$$(“search”).value;
    }
    14、文本分散对齐
    iOS
    .tx-w{text-align:justify;text-justify:distribute-all-lines; text-align-last:justify; display:inline-block;}
    Android
    15、如果打包成功后,仅在iOS上面安装验证失败,则考虑上传代码中,页面name有汉字或者有不可识别文件格式,例如.psd文件

  • html5本地存储-localStorage

    html5本地存储有两类。
    localStorage -一般保存在客户端计算机,在移动端浏览器中,一般情况是永久保存
    sessionStorage – 数据保存在当前会话中,或者当前窗口,当前窗口新建的窗口,相关联的标签

    1、在使用之前先检查浏览器是否可以支持Web Storage。

    if(window.localStorage){ 
    } 
    if(window.sessionStorage){
    }

    2、赋值和调取

    var userData={
    name:"www",
    account:"san",
    level:2,
    disbled:true
    }
    //存储userData数据
    localstorage.setItem("userData",JSON.stringify(userData));
    
    //读取userData并赋值给新变量
    var newUserData=JSON.parse(localStorage.getItem("userData"))

     

    3、删除数据

    //删除本地存储的key为那么的Item
    localStorage.removeItem("name");
    
    //删除localStorage所有key/value键值对,Item
    localStorage.clear()

     

    PS:JSON.stringify()把字符串转换成对象;JSON.parse()把对象转换成原来的数据格式。

    手机App实例:

    /**
    * localStorage保存数据
    * @param String key 保存数据的key值
    * @param String value 保存的数据
    */
    function setLocVal(key,value){
    window.localStorage[key] = value;
    }

    /**
    * 根据key取localStorage的值
    * @param String key 保存的key值
    */
    function getLocVal(key){
    if(window.localStorage[key])
    return window.localStorage[key];
    else
    return “”;
    }

    /**
    * 清除缓存
    * @param String key 保存数据的key,如果不传清空所有缓存数据
    */
    function clearLocVal(key){
    if(key)
    window.localStorage.removeItem(key);
    else
    window.localStorage.clear();
    }

    a页面存储

    function openDetails(i){
    var Arr=[‘投保指南’,’投保流程’,’常见问题’];
    setLocVal(‘mName’,JSON.stringify(Arr[i]));
    setLocVal(‘mNo’,JSON.stringify(i)); //
    openNewWin(‘wytb’, ‘wytb.html’);
    }

    b列表页面接收

    var mN = JSON.parse(getLocVal(“mN”));
    var mNn = JSON.parse(getLocVal(“mNo”));

    function showGoods(){
    $toast(‘数据加载中…’);
    if(mNn==2){
    $closeToast();
    $.getJSON(mN, function(data){
    if (status==0&&data&&data.data.length) {
    $closeToast();
    var arrData = data.data;
    var tmpl = ‘<div class=\”ub ub-ac ub-pc ub-pj uinn umar-t c-wh\” ontouchstart=\”zy_touch(\’t-org\’)\” onmousedown=\”zy_touch(\’t-org\’);\” onclick=\”openDetails(\’${href}\’);\”>’
    +'<div class=”ulev-app2″>${title}</div>’
    +'<div class=”arrow ub-img umwh”>’
    +'</div>’
    +'</div>’
    var s = zy_tmpl(tmpl, arrData, zy_tmpl_count(arrData));
    $$(‘mytb’).innerHTML=s;
    Imgclick();
    }else {
    $$(‘mytb’).innerHTML= ‘<div class=”ub ub-ac ub-pc uinn”>暂时没有数据</div>’;
    }
    });
    }else{
    $.getJSON(mN, function(data){
    if (data&&data.length) {
    $closeToast();
    var arrData = data;
    arrData=JSON.stringify(arrData);
    arrData=arrData.replace(/height.*?\/>/gi,”\/>”);
    arrData=JSON.parse(arrData);
    var tmpl = ‘<div class=\”uba b-gra ub ub-ver c-wh uinn umar-t\”>’ +
    ‘<div class=\”ubb b-gra ub uinn3\”>’ +
    ‘<div class=\”t-org ulev-app2\”>${title}</div>’ +
    ‘</div>’ +
    ‘<div class=\”uinnh1 t-gra1 ulev-app2 c-wh\”>’ +
    ‘<span>${text}</span>’ +
    ‘</div>’ +
    ‘</div>’
    var s = zy_tmpl(tmpl, arrData, zy_tmpl_count(arrData));
    $$(‘mytb’).innerHTML=s;
    Imgclick();
    }else {
    $$(‘mytb’).innerHTML= ‘<div class=”ub ub-ac ub-pc uinn”>暂时没有数据</div>’;
    }
    });
    }
    }

    //打开详情页面
    function openDetails(url){
    setLocVal(‘mHref’,JSON.stringify(lPath+’?url=’+url));//存值
    openNewWin(‘wytb_detail’,’wytb_detail.html’);
    }

    //手机相册调取
    function Imgclick(){
    var Img = document.getElementsByTagName(‘img’);
    for (var i = 0; i < Img.length; i++) {
    Img[i].onclick=function(){
    uexImageBrowser.open([this.src]);
    }
    }
    }

     

    c页面-详情页面

    function sortList(){
    $$(‘Info’).innerHTML=””;
    $toast(‘数据加载中…’);
    $.getJSON(liPath, function(data){
    $closeToast();
    if (data!=0) {
    data.content=data.content.replace(/FONT-SIZE: 12pt/gi,””);

    //详情模板

    var liPath = JSON.parse(getLocVal(“mHref”));
    var tmpl = ‘<div class=”ubb b-gra ub uinn3″>’
    +'<div class=”t-org ulev-app2″>’+data.title+'</div>’
    +'</div>’
    +'<div class=”uinnh1 t-gra1 ulev-app2 c-wh”>’
    +'<span>’+data.content+'</span>’
    +'</div>’;
    $$(‘Info’).innerHTML=tmpl;
    }
    else {
    $$(‘Info’).innerHTML= ‘<div class=”ub ub-ac ub-pc uinn”>暂时没有数据</div>’;
    }
    });
    }

     

     

     

     

  • IE浏览器文本模式变为杂项(quirks)页面变形

    00000
    今天正好解决了这个问题,在QQ群里面也碰到有人在问这个问题,故写此记录下。(这个问题让我怀疑在三年前我遇到过,但是没有记录)
    问题描述:在ie10到ie7标准模式下没有问题,在ie7\ie8或IE9浏览器文本模式变为杂项页面变形或弹出层不居中;或文件上传至服务器后出现变形。
    不清楚什么模式,可以F12看或者
    alert( document.compatMode );
    解决方法:

    先瞧瞧页面是html或者jsp
    1、代码规范问题
    文件头

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    换成

    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0//EN” “w3.org/TR/html4/strict.dtd”>
    就不会出现Quirks Model了,问题也就解决了
    并且

    <!DOC.......

    前面不要有任何文本。

    2、设置为当前浏览器最高版本
    3、把<%@ page language=”java” contentType=”text/html; charset=UTF-8″%> 成<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 

    pageEncoding是jsp文件本身的编码
    contentType的charset是指服务器发送给客户端时的内容编码
    JSP要经过两次的“编码”,第一阶段会用pageEncoding,第二阶段会用utf-8至utf-8,第三阶段就是由Tomcat出来的网页, 用的是contentType。
    第一阶段是jsp编译成.java,它会根据pageEncoding的设定读取jsp,结果是由指定的编码方案翻译成统一的UTF-8 JAVA源码(即.java),如果pageEncoding设定错了,或没有设定,出来的就是中文乱码。
    第二阶段是由JAVAC的JAVA源码至java byteCode的编译,不论JSP编写时候用的是什么编码方案,经过这个阶段的结果全部是UTF-8的encoding的java源码。

    ps:涉及知识

    <!--常见写法如下:-->
    <meta http-equiv="X-UA-Compatible" content="IE=7">  
    <!--以上代码告诉IE浏览器,无论是否用DTD声明文档标准,IE8/9都会以IE7引擎来渲染页面。  -->
    <meta http-equiv="X-UA-Compatible" content="IE=8">  
    <!--以上代码告诉IE浏览器,IE8/9都会以IE8引擎来渲染页面。 --> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge">  
    <!--以上代码告诉IE浏览器,IE8/9及以后的版本都会以最高版本IE来渲染面。-->  
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9">  
    <meta http-equiv="X-UA-Compatible" content="IE=7,9">  
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <!--以上代码IE=edge告诉IE使用最新的引擎渲染网页,chrome=1则可以激活Chrome Frame-->

     

    怪异原理有个网友总结的好啊网站地址:http://www.ibm.com/developerworks/cn/web/1310_shatao_quirks/