将相对img src更改为javascript

时间:2017-05-13 17:14:38

标签: javascript filemaker

我正在编写Filemaker中的运动事件日志数据库。

webviewer包含一个用Javascript编写的计时器/时钟 Filemaker webviewer需要所有img src的完全绝对路径,因此必须将相对路径更改为绝对路径。
对于简单/单一的功能来说并不困难,但对于我来说功能却相当困难。

该功能本身将周期/间歇标志(第1,第2,第3,第4-)置于定时器数字之上。

第一部分(对于i循环)使符号变暗。第二部分将当前周期/间歇设置为由函数参数传递的亮(FULL) 当我手动将最后计算的Lamp.src = Lamp.src.replace('Dim','Full');更改为Lamp.src = 'http://full path';时,该符号会再次出现在顶部,但之后该功能无效。

// Show the current period/intermission sign in the display
function displayPeriode( pId ) {
   var i, idTab=['per1','pau1','per2','pau2','per3'];
   for ( i in idTab ) {
      try {
         var Lamp = document.getElementById(idTab[i]);
             Lamp.src = Lamp.src.replace('Full','Dim');
      } catch(e){};
   };
   try {
      Lamp = document.getElementById( pId );
      Lamp.src = Lamp.src.replace('Dim','Full');
   } catch(e){};
};

有人可以让这个工作,请解释因为我喜欢理解。

1 个答案:

答案 0 :(得分:0)

试试这个:

// Show the current period/intermission sign in the display
function displayPeriode( pId ) {
   var i, idTab=['per1','pau1','per2','pau2','per3'];
   for ( i in idTab ) {
      try {
         var Lamp = document.getElementById(idTab[i]);
             Lamp.src = "http://full_path/Dim.jpg";
      } catch(e){};
   };

   try {
      Lamp = document.getElementById( pId );
      Lamp.src = "http://full_path/Full.jpg";
   } catch(e){};
};