2014-02-08 99 views
0

有人创建了这个脚本一些链接添加到我已经安装了强制新生产线

var fauxTab = new Array(); 

fauxTab[0] = new Array("History","http://%LIVESCORINGHOST%/%YEAR%/home/%LEAGUEID%?MODULE=MESSAGE3","_top"); 
fauxTab[1] = new Array("Scoreboard","http://%LIVESCORINGHOST%/%YEAR%/home/%LEAGUEID%?MODULE=MESSAGE7","_top"); 
fauxTab[2] = new Array("Forum","http://forums.thehuddle.com/index.php?/forum/156-the-empire/","_blank"); 


try {for (var x=0;x<fauxTab.length;x++) document.getElementById("homepagetabs").innerHTML+="<li onclick='window.open(\""+fauxTab[x][1]+"\",\""+fauxTab[x][2]+"\")'>"+fauxTab[x][0]+"</li>"} catch(er) {} 

所创建没有李类之间的换行符的HTML现有的选项卡菜单所以它看起来像这样

<li onclick="window.open(&quot;http://www27.myfantasyleague.com/2014/home/15356?MODULE=MESSAGE3&quot;,&quot;_top&quot;)">History</li><li onclick="window.open(&quot;http://www27.myfantasyleague.com/2014/home/15356?MODULE=MESSAGE7&quot;,&quot;_top&quot;)">Scoreboard</li><li onclick="window.open(&quot;http://forums.thehuddle.com/index.php?/forum/156-the-empire/&quot;,&quot;_blank&quot;)">Forum</li> 

如何脚本编辑所以每个班级里一个换行符和HTML出现这样

<li onclick="window.open(&quot;http://www27.myfantasyleague.com/2014/home/15356?MODULE=MESSAGE3&quot;,&quot;_top&quot;)">History</li> 
<li onclick="window.open(&quot;http://www27.myfantasyleague.com/2014/home/15356?MODULE=MESSAGE7&quot;,&quot;_top&quot;)">Scoreboard</li> 
<li onclick="window.open(&quot;http://forums.thehuddle.com/index.php?/forum/156-the-empire/&quot;,&quot;_blank&quot;)">Forum</li> 

我想在我的css中均匀地分配“justify”选项卡,但是因为这些添加选项卡在HTML中没有单独的行空间,所以它将无法正常工作。

回答

1

添加一个换行符标签或br标签:

document.getElementById("homepagetabs").innerHTML+="<li onclick='window.open(\""+fauxTab[x][1]+"\",\""+fauxTab[x][2]+"\")'> 
"+fauxTab[x][0]+"</li><br>" 
//     ^This 

使你的代码看起来像:

var fauxTab = new Array(); 

fauxTab[0] = new Array("History","http://%LIVESCORINGHOST%/%YEAR%/home/%LEAGUEID%?MODULE=MESSAGE3","_top"); 
fauxTab[1] = new Array("Scoreboard","http://%LIVESCORINGHOST%/%YEAR%/home/%LEAGUEID%?MODULE=MESSAGE7","_top"); 
fauxTab[2] = new Array("Forum","http://forums.thehuddle.com/index.php?/forum/156-the-empire/","_blank"); 


try {for (var x=0;x<fauxTab.length;x++) document.getElementById("homepagetabs").innerHTML+="<li onclick='window.open(\""+fauxTab[x][1]+"\",\""+fauxTab[x][2]+"\")'>"+fauxTab[x][0]+"</li><br>"} catch(er) {} 

,或者你也可以使用JavaScript字符串换行符(\n,Opera9和Windows上的IE8会将其转换为\r\n):

document.getElementById("homepagetabs").innerHTML+="<li onclick='window.open(\""+fauxTab[x][1]+"\",\""+fauxTab[x][2]+"\")'> 
"+fauxTab[x][0]+"</li>\n" 
//     ^This 

使你的代码看起来像:

var fauxTab = new Array(); 

fauxTab[0] = new Array("History","http://%LIVESCORINGHOST%/%YEAR%/home/%LEAGUEID%?MODULE=MESSAGE3","_top"); 
fauxTab[1] = new Array("Scoreboard","http://%LIVESCORINGHOST%/%YEAR%/home/%LEAGUEID%?MODULE=MESSAGE7","_top"); 
fauxTab[2] = new Array("Forum","http://forums.thehuddle.com/index.php?/forum/156-the-empire/","_blank"); 


try {for (var x=0;x<fauxTab.length;x++) document.getElementById("homepagetabs").innerHTML+="<li onclick='window.open(\""+fauxTab[x][1]+"\",\""+fauxTab[x][2]+"\")'>"+fauxTab[x][0]+"</li>\n"} catch(er) {} 
+0

完美的解释TY! – MShack

0

只需添加一个brakeline <br>

</li><br>"} catch(er) {} 
0

您应该使用换行符\ n

+="<li onclick='window.open(\""+fauxTab[x][1]+"\",\""+fauxTab[x][2]+"\")'>"+fauxTab[x][0]+"</li>\n"