Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde pessoal !
Como ainda estou dando os primeiros passos com JS, estou com uma dúvida bem básica.
Estou acostumado a escrever os scripts dentro do <head>. Como vou ter de usar o código para outras páginas quero utilizá-lo num arquivo externo, mas não estou conseguindo fazer a adaptação =\
Segue abaixo o código:
[left][left]function resize_thumb()
{
var scaleTo = document.getElementById("miniatura").offsetWidth* 100 / document.getElementById("thumb").width ;
var widthTo = (scaleTo * document.getElementById("thumb").width) / 100;
var heightTo = (scaleTo * document.getElementById("thumb").height) / 100;
document.getElementById("thumb").width = widthTo;
document.getElementById("thumb").height = heightTo;
}
var images =new Array ('./images/hist_1_5_1.jpg' ,'./images/hist_1_5_2.png' );
var thumbs =new Array ('./images/geo_1_5_1_thumb.jpg','./images/geo_1_5_2_thumb.png');
var ind_image = 0 ;
var ult_image = images.length -1 ;
function swap_image(next)
{
ind_image = ind_image + next;
if(ind_image > ult_image)
{
ind_image = 0
};
if(ind_image < 0)
{
ind_image = ult_image
};
document.getElementById('image').src = images[ind_image];
document.getElementById('thumb').src = images[ind_image];
}Carregando comentários...