<script src="http://www.bengou.com/js/jquery.cookie.js"></script>
<script src="http://www.bengou.com/js/jquery.image.js"></script>
<script src="http://www.bengou.com/js/cartoon_common.js"></script>
<script type="text/javascript" src="http://www.bengou.com/js/cartoon_detail_scroll.js"></script>
小白一个,为啥上面这几个js下载到本地后是乱码,打不开,直接在Chrome上打开后只有中文字符是乱码,但直接复制下来也用不了!希望大神帮助啊...

解决方案 »

  1.   

    就是utf-8的编码文件啊,没啥特殊。
      

  2.   

    没乱码呀/**
     * Cookie plugin
     *
     * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
     * Dual licensed under the MIT and GPL licenses:
     * http://www.opensource.org/licenses/mit-license.php
     * http://www.gnu.org/licenses/gpl.html
     *
     *//**
     * Create a cookie with the given name and value and other optional parameters.
     *
     * @example $.cookie('the_cookie', 'the_value');
     * @desc Set the value of a cookie.
     * @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});
     * @desc Create a cookie with all available options.
     * @example $.cookie('the_cookie', 'the_value');
     * @desc Create a session cookie.
     * @example $.cookie('the_cookie', null);
     * @desc Delete a cookie by passing null as value.
     *
     * @param String name The name of the cookie.
     * @param String value The value of the cookie.
     * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
     * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
     *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
     *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
     *                             when the the browser exits.
     * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
     * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
     * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
     *                        require a secure protocol (like HTTPS).
     * @type undefined
     *
     * @name $.cookie
     * @cat Plugins/Cookie
     * @author Klaus Hartl/[email protected]
     *//**
     * Get the value of a cookie with the given name.
     *
     * @example $.cookie('the_cookie');
     * @desc Get the value of a cookie.
     *
     * @param String name The name of the cookie.
     * @return The value of the cookie.
     * @type String
     *
     * @name $.cookie
     * @cat Plugins/Cookie
     * @author Klaus Hartl/[email protected]
     */
    jQuery.cookie = function(name, value, options) {
        if (typeof value != 'undefined') { // name and value given, set cookie
            options = options || {};
            if (value === null) {
                value = '';
                options.expires = -1;
            }
            var expires = '';
            if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
                var date;
                if (typeof options.expires == 'number') {
                    date = new Date();
                    date.setTime(date.getTime() + (options.expires * 1000));
                } else {
                    date = options.expires;
                }
                expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
            }
            var path = options.path ? '; path=' + options.path : '';
            var domain = options.domain ? '; domain=' + options.domain : '';
            var secure = options.secure ? '; secure' : '';
            document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
        } else { // only name given, get cookie
            var cookieValue = null;
            if (document.cookie && document.cookie != '') {
                var cookies = document.cookie.split(';');
                for (var i = 0; i < cookies.length; i++) {
                    var cookie = jQuery.trim(cookies[i]);
                    // Does this cookie string begin with the name we want?
                    if (cookie.substring(0, name.length + 1) == (name + '=')) {
                        cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                        break;
                    }
                }
            }
            return cookieValue;
        }
    };
      

  3.   


    $(function(){
    var jPicList = $('#pic-list');
    var sTimer =null;

    cartoon_init();

    $(window).scroll(function scrollHandler(){
    clearTimeout(sTimer);
    sTimer = setTimeout(function() {
    if(window.loaded == 1){
    $(window).unbind("scroll", scrollHandler);
    }
    var c=document.documentElement.clientHeight || document.body.clientHeight, t=$(document).scrollTop();
    if(t+c >= jPicList.offset().top+jPicList.height()){
    loadMore();
    }
    }, 
    100
    );
    }); function loadMore() {
    if (window.loaded == 1) return;
    if( currentPageIndex < picTree.length ){
    showPic();
    }else{
    window.loaded = 1;
    $("#bottom_chapter").show();//底部显示上一话下一话
    ad_show(cid);//显示广告
    //lastPageTips();
    }
    }

    //加载图片
    var loadPageIndex = -1;
    var intervalHandle = setInterval(function loadPic(){
    if( (currentPageIndex +1) == loadPageIndex ){
    return false;
    }
    loadPageIndex = currentPageIndex+1;

    if( loadPageIndex >= picTree.length ){
    clearInterval(intervalHandle);
    return ;
    }
    var c=document.documentElement.clientHeight || document.body.clientHeight, t=$(document).scrollTop();
    if(t+c+6000 >= jPicList.offset().top+jPicList.height()){
    //加载图片,加载完之后立即显示
    $.preLoadImg( pic_base + picTree[loadPageIndex], function(){ showPic(); });
    }
    },
    100);

    var lastPageIndex = -1;

    function showPic(){
    //当前图片尚未加载完之前,不显示下一张图片
    if( currentPageIndex == lastPageIndex){
    return false;
    }
    lastPageIndex = currentPageIndex;

    var num = currentPageIndex + 1;
    var imgStr = '<img src="' + pic_base + picTree[currentPageIndex] + '" alt="" />';
    var imgInfo = '<p class="img_info">(' + num + '/' + picTree.length +')</p>';
    jPicList.append( imgStr );

    var lastImgObj = $('#pic-list img').last();
    lastImgObj.hide();
    $('#loading').show();
    //自适应大小
    lastImgObj.imgAutoSize( imageMaxWidth,
    0,
    function(){
    $('#loading').hide();
    lastImgObj.show();
    jPicList.append(imgInfo);
    currentPageIndex++;
     }
    );

    }
    showPic(); $("#pic-list").drag(); //图片拖拽功能
    $("#chapter_title").append('  共' + picTree.length + '页');

    //观看记录与记号
    addHistory(cid, getUserActionData(currentPageIndex));
    var lastHistoryPageIndex = currentPageIndex;
    var startHistoryPageIndex = lastHistoryPageIndex;
    function getPageindex(){
    var images_height = jPicList.offset().top;;
    var c=document.documentElement.clientHeight || document.body.clientHeight, t=$(document).scrollTop();
    var scroll_height = t+c;
    var pageIndex = startHistoryPageIndex;
    $('#pic-list img').each(function(i){
    images_height += $(this).height();
    if( images_height > scroll_height){
    var num = startHistoryPageIndex + i -2;
    num = (num > startHistoryPageIndex) ? num : startHistoryPageIndex;
    pageIndex = (num < picTree.length) ? num : picTree.length-1;
    return false;
    }
    });
    return pageIndex;
    }
    setInterval(function(){
    var num = getPageindex()  
    if( num > lastHistoryPageIndex ){
    lastHistoryPageIndex = num;
    addHistory(cid, getUserActionData(num));
    }
    return false;
    },3000);

    $(".btn-").click(function(){
    addMark(cid, getUserActionData(getPageindex()));
    bengou_alert('做个记号','记号做好了!');
    return false;
    });

    //顶部广告
    var html = '<div style="margin-left:auto; margin-right:auto; width:870px; height:215px; margin-top:5px; margin-bottom:15px; line-height:95px;">'
     +'<a href="http://sz.duowan.com/s/gamespread/index.html?__yaadid=1&__yarso=FROM_HJ_BENGOU&__yawebid=1&game=cysg&server=&tip=on" target="_blank">'
     +'<img src="/game/haizeiwang/870-80.gif" style=" margin-top:10px;"/>'
     +'</a>'
     +'<a href="http://tu.duowan.com/m/xemh?bengou" target="_blank">'
     +'<img src="/game/tuku/870X90.jpg"  style=" margin-top:10px;"/>'
     +'</a>'
     +'</div>'; $(".tips-box-1").hide();  
    $(".tips-box-1").before(html);
    });
      

  4.   


    var currentPageIndex = 0; //当前页下标
    var currentChapterIndex = 0; //当前章节下标
    var pageSize = 1;
    var imageMaxWidth = window.screen.width >= 1280 ? 1280 : 1024;//根据分辨率大小,设定图片自适应宽度//获取参数
    function getSetting(name){
    return $.cookie('bg_setting_' + name);
    }//设置参数
    function setSetting(name, value, day){
    if(typeof day == 'undefined') day = 30;
    $.cookie('bg_setting_' + name, value, {expires: day*3600*24, path: '/'});
    }

    //弹出框输出信息
    function bengou_alert(title, msg, fn){
    $("#win-alert-title").html( title );
    $("#win-alert-msg").html( msg );
    if( typeof fn == 'function' ){
    $("#win-alert-close,#win-alert-ok").unbind('click');
    $("#win-alert-close,#win-alert-ok").bind('click', fn);
    }
    KISSDW.popupBox("none", {boxSelector: "#win-alert"});
    }//判断是否是翻页模式
    function isPageRead(){
    return  ( /mode=1/.test(window.location.href) );
    }//通过键值获取字符
    function getKeyString(code) {
    var hotKeys = {
    specialKeys: { 8: 'backspace',27: 'esc', 9: 'tab', 32:'space', 13: 'return', 145: 'scroll', 
    20: 'capslock', 144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',
    35:'end', 33: 'pageup', 34:'pagedown', 37:'←', 38:'↑', 39:'→',40:'↓',109: '-', 
    112:'f1',113:'f2', 114:'f3', 115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8', 
    120:'f9', 121:'f10', 122:'f11', 123:'f12', 191: '/' , 16:"shift" , 17:"ctrl",18:"alt"},
    shiftNums: { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&", 
    "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<", 
    ".":">",  "/":"?",  "\\":"|" },
     numKeys : { 106: '*', 
    107: '+', 109: '-', 110: '.', 111 : '/'
    }
    };
    for(var keyString in hotKeys) {
    for(var codeKeys in hotKeys[keyString]){
    if(codeKeys == code)
    return hotKeys[keyString][codeKeys];
    }
    }
    var character = String.fromCharCode(code).toUpperCase();
    var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
    if(str.indexOf(character) != -1){
    return character;
    }else{
    return "";
    }
    }

    //漫画数据初始化
    function cartoon_init(){
    currentPageIndex = getPageIndex();
    currentChapterIndex = getChapterIndex();
    pageSize = getSetting('images_num') > 0 ? parseInt(getSetting('images_num')) : pageSize;
    imageMaxWidth = ( 1 == getSetting('image_auto_size_off') ) ?  2048 : imageMaxWidth; if( null == currentPageIndex && null == currentChapterIndex ) {
    bengou_alert('出错了', '该漫画不存在或者已被删除!', function(){ window.location.href = '/'; } );
    }

    if( null !== currentPageIndex && null == currentChapterIndex ) {
    bengou_alert('提示', '该漫画已被替换为清晰版!', function(){ window.location.href = $('#cartoon_url').attr('href'); } );
    }
    }//获取当前页下标
    function getPageIndex(){
    for(var i =0; i < picTree.length; i++){
    if(  currentPic == picTree[i].substr(0,13)){
    return i - parseInt(i%1);
    }
    }
    return null;
    }//获取当前章节下标
    function getChapterIndex(){
    for(var i =0; i < chapterTree.length; i++){
    if( currentChapterid == chapterTree[i].substr(chapterTree[i].length-32, 13)){
    return i;
    }
    }
    return null;
    }//获取页面地址
    function getPageUrl(page){
    var url = chapter_base + picTree[ page ].substr(0,13) + '.html';
    if( isPageRead() ){
    url += '?mode=1';
    }
    return url;
    }//页面跳转
    function goPage(page){
    window.location.href = getPageUrl(page);
    }//章节跳转
    function goChapter(chapter){
    var url = chapterTree[ chapter ];
    if( isPageRead() ){
    url += '?mode=1';
    }
    window.location.href = url;
    }//最后一页提示
    function lastPageTips(){
    if( currentChapterIndex < chapterTree.length - 1 ){
    if( 1 == getSetting('tips_page') ){
    //翻页模式自动跳转
    if( isPageRead() ) {
    nextChapter();
    }
    }else{
    KISSDW.popupBox("none", {boxSelector: "#win-page-last"});
    }
    }else{
    lastChapterTips();//最后一话
    }
    }//最后一话提示
    function lastChapterTips(){
    KISSDW.popupBox("none", {boxSelector: "#win-hua-last"});
    }//上一页
    function prePage(){
    if( currentPageIndex  - pageSize >= 0 ) {
    goPage( currentPageIndex - pageSize );
    } else {
    $("#win-first-title").html('这是第一页了!');
    KISSDW.popupBox("none", {boxSelector: "#win-first"});
    }
    }//下一页
    function nextPage(){
    if( currentPageIndex < picTree.length - pageSize ) {
    goPage( currentPageIndex + pageSize );
    } else {
    lastPageTips();
    }
    }//首页
    function firstPage(){
    goPage(0);
    }//末页
    function lastPage(){
    mod = picTree.length % pageSize;
    page = ( mod == 0 ) ? picTree.length-pageSize : picTree.length-mod;
    goPage( page );
    }//上一话
    function preChapter(){
    if( currentChapterIndex > 0 ) {
    goChapter( currentChapterIndex - 1 );
    } else {
    $("#win-first-title").html('这是第一话了!');
    KISSDW.popupBox("none", {boxSelector: "#win-first"});
    }
    }//下一话
    function nextChapter(){
    if( currentChapterIndex < chapterTree.length - 1 ) {
    goChapter( currentChapterIndex + 1 );
    } else {
    lastChapterTips();
    }
    }

    function getUserActionData(num){
    var data = [];
    data[0]=[$("#cartoon_url").attr('href'), $("#cartoon_url").html()];
    data[1]=[getPageUrl(0), $("#chapter_title").html().replace(/\s共\d+页$/, '')];
    data[2]=[getPageUrl(num), '第' + (num+1) + '页'];
    return data;
    }//广告显示
    function ad_show(cid){
    if( currentChapterIndex < chapterTree.length - 1 ){
     return false;
    }
    cid_arr=['hyrz008081909','ss008081917','hzw0008081910'];
    for(var i in cid_arr){
    if( cid == cid_arr[i]){
    var html = '<div style="margin-left:auto; margin-right:auto; width:870px; height:80px;">'
     +'<a href="http://sz.duowan.com/s/gamespread/index.html?__yaadid=1&__yarso=FROM_HJ_BENGOU&__yawebid=1&game=cysg&server=&tip=on" target="_blank">'
     +'<img src="/game/haizeiwang/870-80.gif" />'
     +'</a>'
     +'</div>';
    if( isPageRead() ){
    $('#current-page').parent().after(html);
    }else{
    $('#bottom_chapter').after(html);
    }
    break;
    }  
    }