标签 JS 下的文章

JS - 转义

<script>
var func = "<a href='?uuid=&quot;" + <?php echo $uuid;?> + "&quot;' onclick='if(confirm(&quot;确认要删除吗?&quot;)) return true;else return false;'>删除</a>";
</script>

JS - 全部选择、取消全部选择 - 2

<script>
function SelectAll() {
    var operate = $(".member_tab tr");
    var bool = $("#allchecked").attr('checked');
    operate.each(function () {
        $(this).find('input[type=checkbox]').attr("checked", bool ? true : false);
    });
}
</script>
<table class="member_tab" width="100%">
<!--{if $peoplestr}-->
    <tr>
        <th style=" text-align:center;" width="4%">
            <input name="xuan" type="checkbox" id="allchecked" onclick="SelectAll()" />
        </th>
        <th><span>|</span>用户名</th>
        <th><span>|</span>姓名</th>
        <th><span>|</span>手机号</th>
        <th><span>|</span>邮箱</th>
    </tr>
    <!--{foreach item=people from=$peoplestr name=foo}-->
    <tr>
        <td style="text-align:center;">
        <!--{if $people.uuid neq $uuid}-->
        <input name="delte" type="checkbox" value="<!--{$people.id}-->" />
        <!--{/if}-->
        </td>
        <td><!--{$people.username}--></td>
        <td><!--{$people.name}--></td>
        <td><!--{$people.move}--></td>
        <td><!--{$people.email}--></td>
    </tr>
    <!--{/foreach}-->
<!--{/if}-->
</table>

阅读全文

JS - 框架内页跳出框架并重定向

退出代码

<script>window.parent.location.href='/login';</script>

在登录页增加如下代码

<script>
if (window != top) {
    top.location.href = location.href;
}
</script>

PHP - AJAX - 省市区三级联动

php

public function indexAction() {
    //获取父级代号pid
    $pid = $this->getParam('pcode');
    //数据查询
    $areaModel = new Model_Area();
    $fields = "*";
    $whereArr[] = array('pid', $pid);
    $areadetail = $areaModel->getArea($fields, $whereArr);
    //var_dump($areadetail);
    echo json_encode($areadetail);
}

阅读全文

Editor - 百度编辑器

实例化编辑器

var ue = UE.getEditor('editor2', {
    toolbars: [[
        'source', '|', 'undo', 'redo', '|',
        'bold', 'italic', 'underline', '|',
        'selectall', 'cleardoc', '|',
        'fontfamily', 'fontsize', '|',
        'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
        'simpleupload', '|',
        'removeformat', '|'
    ]],
    iframeCssUrl: '../ueditor/themes/editor2.css',
    initialFrameHeight:500,
    enableAutoSave: false,
    enableContextMenu: false,
    elementPathEnabled : false,
    focus:false,
    autoHeightEnabled:false
});

阅读全文

JS - 数组的交叉合并

js

var arr1 = new Array(3);
arr1[0] = "a";
arr1[1] = "b";
arr1[2] = "c";
arr1[3] = "d";
var arr2 = new Array(3);
arr2[0] = "x";
arr2[1] = "y";
arr2[2] = "z";
console.log(arr1);
console.log(arr2);
var length = arr1.length;
console.log(length);
var arr3 = new Array(3);
for(var j=0;j<length;j++){
    var a = 2*j;
    console.log(a);
    var b = 2*j+1;
    console.log(b);
    arr3[a]=arr1[j];
    arr3[b]=arr2[j];
}
console.log(arr3);
var str = arr3.join("");
console.log(str);
//axbyczd

JS - 点击直接下载

js

function download(src) {
    var a = document.createElement('a');
    a.setAttribute("href", src);
    a.setAttribute("download", "");
    var evObj = document.createEvent('MouseEvents');
    evObj.initMouseEvent( 'click', true, true, window, 0, 0, 0, 0, 0, false, false, true, false, 0, null);
    a.dispatchEvent(evObj);
};

阅读全文