Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript变量抛出错误中的句点我似乎无法消除_Javascript_Jquery_Replace_Escaping_Period - Fatal编程技术网

javascript变量抛出错误中的句点我似乎无法消除

javascript变量抛出错误中的句点我似乎无法消除,javascript,jquery,replace,escaping,period,Javascript,Jquery,Replace,Escaping,Period,这是我用来查询google finance的脚本,它带回了一些股票,在股票行情中有一个句号,我需要用一个破折号来代替它,但出于某种原因,这让我非常悲伤。除了一个MOG-A之外,其他所有的股票代码都在hover上工作。它只是给了我“失踪”;before语句的错误,没有详细信息 ( function($) { $(document).ready(function(){ $.getJSON('https://finance.google.com/finance/info?client=ig&am

这是我用来查询google finance的脚本,它带回了一些股票,在股票行情中有一个句号,我需要用一个破折号来代替它,但出于某种原因,这让我非常悲伤。除了一个MOG-A之外,其他所有的股票代码都在hover上工作。它只是给了我“失踪”;before语句的错误,没有详细信息

( function($) {
$(document).ready(function(){

  $.getJSON('https://finance.google.com/finance/info?client=ig&q='+stocklist+'&    callback=?',function(response){
for (var i = 0; i < response.length; i++) {
    var stockInfo = response[i];
    if (stockInfo.c.indexOf("-") != -1) {var scolor = "red";} else {var scolor =     "green";}
    var finvizt = stockInfo.t.replace('\.','\-');
    var stockString ='<div style="width:210px;position:relative;"     class="stockWrapper">';
    stockString +='<span class="stockPrice" style="margin-left:-10px"><a class="slink"     name="slink'+stockInfo.t+'" href="http://finviz.com    /quote.ashx?t='+finvizt+'" onMouseOver="var         newimg'+stockInfo.t+'=img_create(\''+escape(stockInfo.t)+'    \');slink=getElementById(\'slink'+stockInfo.t+'\');thelink=this;var arx=getPos(thelink);     var posx=arx[0]+90;var posy=arx[1]-75;var         x=document.getElementById(\'stock'+stockInfo.t+'\');x.style.position=\'absolute    \';x.style.display=\'block\';x.style.left=posx+\'px\';x.style.top=posy+\'px\';"     onMouseOut="document.getElementById(\'stock'+stockInfo.t+'\').style.display=\'none\';"     target="external">'+stockInfo.t+'</a></span>';
    stockString +='<span class="stockPrice" style="position:absolute;right:120px"     title="'+stockInfo.ltt+'">'+stockInfo.l+'  </span>';
    stockString +='<span class="stockChange" style="color:'+scolor+';position:absolute;    right:75px">'+stockInfo.c+'</span>';
    stockString +='<span class="stockChange" style="color:'+scolor+';position:absolute;    right:25px">'+stockInfo.cp+'%</span>';
    stockString +='</div>';
    $('.stockTick').prepend(stockString);
    }
  });

});
 } ) ( jQuery );
所有的逃逸,unescape的东西都被添加为一种手段,试图在没有运气的情况下修复它。我意识到代码很混乱,非常感谢您的帮助


左边是投资组合标签的示例页面,MOG。finviz中的MOG-A才是真正的作品

问题在于onmouseover属性中的内联Javascript:

<a class="slink" 
   name="slinkMOG.A" 
   href="http://finviz.com/quote.ashx?t=MOG-A" 
   onmouseover="var newimgMOG.A=img_create('MOG.A');slink=getElementById('slinkMOG.A');thelink=this;var arx=getPos(thelink); var posx=arx[0]+90;var posy=arx[1]-75;var x=document.getElementById('stockMOG.A');x.style.position='absolute';x.style.display='block';x.style.left=posx+'px';x.style.top=posy+'px';" onmouseout="document.getElementById('stockMOG.A').style.display='none';"
   target="external">MOG.A</a>
语句var newimgMOG.A=img_create'MOG.A';无效,因为您不能拥有。在变量名中

在我看来,似乎从未使用过变量名,所以您可以将其更改为img_create'MOG.A'

这是来自viewtopic.php,而不是Javascript

<a class="slink" 
   name="slinkMOG.A" 
   href="http://finviz.com/quote.ashx?t=MOG-A" 
   onmouseover="var newimgMOG.A=img_create('MOG.A');slink=getElementById('slinkMOG.A');thelink=this;var arx=getPos(thelink); var posx=arx[0]+90;var posy=arx[1]-75;var x=document.getElementById('stockMOG.A');x.style.position='absolute';x.style.display='block';x.style.left=posx+'px';x.style.top=posy+'px';" onmouseout="document.getElementById('stockMOG.A').style.display='none';"
   target="external">MOG.A</a>