2014-03-12 58 views
0

我喜歡爲這些圖像添加曲線邊緣,這些圖像已經存在於javascript中。將曲線添加到已在javascript中的圖像

var howOften = 5; //number often in seconds to rotate 
var current = 0; //start the counter at 0 
var ns6 = document.getElementById&&!document.all; //detect netscape 6 

// place your images, text, etc in the array elements here 
var items = new Array(); 

items[0]="<a href='link.htm' ><img alt='Corinthians match'src='../images/1sts/1sts_corithas.jpg' width='300' height='184' border='0' /></a>"; //a linked image 
items[1]="<a href='link.htm'><img alt='Ago playing' src='../images/1sts/ago_1sts.jpg' width='300' height='184' border='0' /></a>"; //a linked image 
items[2]="<a href='link.htm'><img alt='Celebration' src='../images/1sts/annadale_goal_final.jpg' width='300' height='184' border='0' /></a>"; //a linked image 
items[3]="<a href='link.htm'><img alt='Defender' src='../images/1sts/defender_1sts.jpg' width='300' height='184'' border='0' /></a>"; //a linked image 
items[4]="<a href='link.htm'><img alt='kirk club medal' src='../images/1sts/kirk_cup_medal.jpg' width='300' height='184' border='0' /></a>"; //a linked image 

function rotater1() { 
document.getElementById("placeholder").innerHTML = items[current]; 
current = (current==items.length-1) ? 0 : current + 1; 
setTimeout("rotater()",howOften*1000); 
} 

function rotater() { 
if(document.layers) { 
    document.placeholderlayer.document.write(items[current]); 
    document.placeholderlayer.document.close(); 
} 
if(ns6)document.getElementById("placeholderdiv").innerHTML=items[current] 
    if(document.all) 
     placeholderdiv.innerHTML=items[current]; 

current = (current==items.length-1) ? 0 : current + 1; //increment or reset 
setTimeout("rotater()",howOften*1000); 
} 

林不知道如何添加它在不破壞代碼

+0

'//檢測網景6'我不認爲你真的不必擔心這一點... –

+0

你是什麼意思的「彎曲的邊緣」?圓角或斜角? – gtr1971

+0

得到它排序謝謝,我不知道如何使邊界半徑與js中的圖像一起工作。 – akirk541

回答

0

我強烈建議樣式使用css(如果這是你的曲線的意思)的圓角,而不是JavaScript。 對於每個項目,添加一個css類,比如說rounded-corners。然後,在css文件中添加這條規則:

.rounded-corners { 
    border-radius: 5px; 
    -webkit-border-radius: 5px; 
    -moz-border-radius: 5px; 
} 

以作爲一個例子項目[0],它會成爲:

items[0]="<a href='link.htm' ><img class='rounded-corners' alt='Corinthians match'src='../images/1sts/1sts_corithas.jpg' width='300' height='184' border='0' /></a>"; 
+0

這是我使用的解決方案謝謝,我現在排序。 – akirk541