javascript-无法加载以下源代码:http://localhost/js/m.js [英] javascript - Failed to load source for: http://localhost/js/m.js

查看:45
本文介绍了javascript-无法加载以下源代码:http://localhost/js/m.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么哦,为什么哦,为什么...我不知道为什么我不断收到此错误.我想我可能会哭.

Why oh why oh why... I can't figure out why I keep getting this error. I think I might cry.

/*** common functions  */
function GE(id) { return document.getElementById(id); }

function changePage(newLoc) {
   nextPage = newLoc.options[newLoc.selectedIndex].value

   if (nextPage != "")
   {
      document.location.href = nextPage
   }
 }

function isHorizO(){
  if (navigator.userAgent.indexOf('iPod')>-1)
    return (window.orientation == 90 || window.orientation==-90)? 1 : 0;
   else   return 1;

}

function ShowHideE(el, act){
    if (GE(el)) GE(el).style.display = act;
}

function KeepTop(){
    window.scrollTo(0, 1);
}

/* end of common function */

var f = window.onload; 
if (typeof f == 'function'){
    window.onload = function() {
        f();
        init();
    }
}else window.onload = init;

function init(){
    if (GE('frontpage')) init_FP();
    else {
        if (GE('image')) init_Image();
        setTimeout('window.scrollTo(0, 1)', 100); 
     }

    AddExtLink();
}

function AddExtLink(){
    var z = GE('extLink');
    if (z){
        z = z.getElementsByTagName('a');
        if (z.length>0){
            z = z[0];
            var e_name = z.innerHTML;
            var e_link = z.href;

            var newOption, oSe;
            if (GE('PSel')) oSe = new Array(GE('PSel'));
            else
                oSe = getObjectsByClassName('PSel', 'select')

            for(i=0; i<oSe.length; i++){
                newOption = new Option(e_name, e_link);
                oSe[i].options[oSe[i].options.length] = newOption;
            }
        }
    }
}

/* fp */
function FP_OrientChanged() {
    init_FP();
}

function init_FP() {
  //  GE('orientMsg').style.visibility = (!isHorizO())? 'visible' : 'hidden';
}

/* gallery */
function GAL_OrientChanged(link){
    if (!isHorizO()){
        ShowHideE('vertCover', 'block');
        GoG(link);
    }
    setTimeout('window.scrollTo(0, 1)', 500);
}
function init_Portfolio() {
 //   if (!isHorizO())
 //       ShowHideE('vertCover', 'block');
}
function ShowPortfolios(){
    if (isHorizO()) ShowHideE('vertCover', 'none');
}

var CurPos_G = 1
function MoveG(dir) {
    MoveItem('G',CurPos_G, dir);
}

/* image */
function init_Image(){
    // check for alone vertical images
    PlaceAloneVertImages();
}
function Img_OrtChanged(){
    //CompareOrientation(arImgOrt[CurPos_I]);
    //setTimeout('window.scrollTo(0, 1)', 500);
}

var CurPos_I = 1
function MoveI(dir) {
    CompareOrientation(arImgOrt[CurPos_I+dir]);
    MoveItem('I',CurPos_I, dir);
}

var arImgOrt = new Array(); // orientation: 1-horizontal, 0-vertical
var aModeName = new Array('Horizontal' , 'Vertical');
var arHs = new Array();

function getDims(obj, ind){
    var arT = new Array(2);

    arT[0] = obj.height; 
    arT[1] = obj.width;


     //arWs[ind-1] = arT;
    arHs[ind] = arT[0];

     //**** (arT[0] > arT[1]) = (vertical image=0)
     arImgOrt[ind] = (arT[0] > arT[1])? 0 : 1;

    // todor debug
    if(DebugMode) {
        //alert("["+obj.width+","+obj.height+"] mode="+((arT[0] > arT[1])? 'verical' : 'hoziontal'))
        writeLog("["+obj.width+","+obj.height+"] mode="+((arT[0] > arT[1])? 'verical' : 'hoziontal')+' src='+obj.src)
    }        
     if (arImgOrt[ind]) {
        GE('mi'+ind).className = 'mImageH';
     }

}
function CompareOrientation(imgOrt){
    var iPhoneOrt = aModeName[isHorizO()];
    GE('omode').innerHTML = iPhoneOrt;
    //alert(imgOrt == isHorizO())
    var sSH = (imgOrt == isHorizO())? 'none' : 'block';
    ShowHideE('vertCover', sSH); 

    var sL = imgOrt? 'H' : 'V';
    if (GE('navig')) GE('navig').className = 'navig'+ sL ;
    if (GE('mainimage')) GE('mainimage').className = 'mainimage'+sL;
    var sPfL = imgOrt? 'Port-<br>folios' : 'Portfolios' ;
    if (GE('PortLnk')) GE('PortLnk').innerHTML = sPfL;

}

function SetGetDim( iMInd){
    var dv = GE('IImg'+iMInd);

    if (dv)   {
        var arI = dv.getElementsByTagName('img');
        if (arI.length>0){
            var oImg =  arI[0];
            oImg.id = 'Img'+iMInd;
            oImg.className = 'imageStyle';
             //YAHOO.util.Event.removeListener('Img'+iMInd,'load');
             YAHOO.util.Event.on('Img'+iMInd, 'load', function(){GetDims(oImg,iMInd);}, true, true);
           //oImg.addEventListener('load',GetDims(oImg,iMInd),true);
        }
    }
}
var occ = new Array();
function PlaceAloneVertImages(){
    var iBLim, iELim;
    iBLim = 0;
    iELim = arImgOrt.length;
    occ[0] = true;
    //occ[iELim]=true;

    for (i=1; i<iELim; i++){
        if ( arImgOrt[i]){//horizontal image
            occ[i]=true;
            continue;
        }else { // current is vertical
            if (!occ[i-1]){//previous is free-alone. this happens only the first time width i=1
                occ[i] = true;
                continue;
            }else {
                if (i+1 == iELim){//this is the last image, it is alone and vertical
                    GE('mi'+i).className = 'mImageV_a'; //***** expand the image container
                }else {
                    if ( arImgOrt[i+1] ){
                        GE('mi'+i).className = 'mImageV_a';//*****expland image container
                        occ[i] = true;
                        occ[i+1] = true;
                        i++;
                        continue;
                    }else { // second vertical image
                        occ[i] = true;
                        occ[i+1] = true;
                        if (arHs[i]>arHs[i+1]) GE('mi'+(i+1)).style.height =  arHs[i]+'px';
                        i++;
                        continue;
                    }
                }
            }

        }


    }
    //arImgOrt

}

function AdjustWebSiteTitle(){

    //if (GE('wstitle')) if (GE('wstitle').offsetWidth > GE('wsholder').offsetWidth) {
    if (GE('wstitle')) if (GE('wstitle').offsetWidth > 325) {
        ShowHideE('dots1','block');
        ShowHideE('dots2','block');
    }
}

function getObjectsByClassName(className, eLTag, parent){
    var oParent;
    var arr = new Array();
    if (parent) oParent = GE(parent); else oParent=document;
    var elems = oParent.getElementsByTagName(eLTag);
    for(var i = 0; i < elems.length; i++)
    {
        var elem = elems[i];
        var cls = elem.className
        if(cls == className){
            arr[arr.length] = elem;
        }
    }
    return arr;
}



////////////////////////////////
///
// todor debug 
var DebugMode = (getQueryVariable("debug")=="1")
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  var sRet = ""
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
        sRet = pair[1];
    }
  }
  return sRet
  //alert('Query Variable ' + variable + ' not found');
} 
var oLogDiv=''
function writeLog(sMes){
    if(!oLogDiv) oLogDiv=document.getElementById('oLogDiv')
    if(!oLogDiv) {
        oLogDiv = document.createElement("div");
        oLogDiv.style.border="1px solid red"
        var o = document.getElementsByTagName("body")
        if(o.length>0) {
            o[0].appendChild(oLogDiv)
        }
    }        
    if(oLogDiv) {
        oLogDiv.innerHTML = sMes+"<br>"+oLogDiv.innerHTML
    }
}

推荐答案

首先,Firebug是您的朋友,请习惯一下.其次,如果您逐个粘贴每个功能和一些支持行,最终将获得以下内容.

First, Firebug is your friend, get used to it. Second, if you paste each function and some supporting lines, one by one, you will eventually get to the following.

var DebugMode =(getQueryVariable("debug")=="1")
函数getQueryVariable(variable)

您不能在定义getQueryVariable之前执行它,但是可以创建将来引用的句柄,但是有所不同.

You can't execute getQueryVariable before it is defined, you can create a handle to a future reference though, there is a difference.

您的代码中还有其他一些潜在的问题,但是在getQueryVariable方法关闭后放置var DebugMode行应该可以正常工作.

There are several other potential issues in your code, but putting the var DebugMode line after the close of the getQueryVariable method should work fine.

这篇关于javascript-无法加载以下源代码:http://localhost/js/m.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆