function swapPic(){
var self = this;
// Preload the Image
var image = new Image();
image.onload = function(){
self.fade();
}
image.src = this.pic;
this.obj.src = this.pic;
this.callback = self.remove;
this.to = 100;
this.from = 0;
this.curr = this.from;
} - Fórum WMO
- → Viewing Profile: Posts: bimonti
Community Stats
- Group Usuários
- Active Posts 2654
- Profile Views 8183
- Member Title Super Veterano
- Age 42 years old
- Birthday March 10, 1983
-
Sexo
Male
9
Neutral
User Tools
Latest Visitors
Posts I've Made
In Topic: Saber Quando Imagem Carregou No Ajax
22/07/2009, 09:37
Isso mesmo, como o Édipo citou. Eu usei isso em uma galeria de fotos para só disparar o efeito de fadeIn quando a imagem terminar de carregar. Em javascript as imagens são objetos também, então você pode instância-los. Vou postar o snippet que eu tenho, mas só se atente ao load da imagem pq essa função é executada por outra.
In Topic: Slideshow - Buscando Dados Do Mysql
05/06/2009, 09:15
Normal ... acontece ... rsrsrs
Abraços.
Abraços.
In Topic: Caixa De Texto/cursor
04/06/2009, 01:59
Sim, é possível mas meio trabalhoso. Veja esse exemplo que eu tinha nos confins do HD:
Enquanto o FF usa selectionStart e selectionEnd, o IE usa selection e selection.createRange ... tem umas coisas interessantes pela internet sobre essas funções, embora o exemplo acima seja bem funcional.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Extended functionaly for textelements</title>
<script type="text/javascript">
function insertAtCaret(obj, text) {
if(document.selection) {
obj.focus();
var orig = obj.value.replace(/\r\n/g, "\n");
var range = document.selection.createRange();
if(range.parentElement() != obj) {
return false;
}
range.text = text;
var actual = tmp = obj.value.replace(/\r\n/g, "\n");
for(var diff = 0; diff < orig.length; diff++) {
if(orig.charAt(diff) != actual.charAt(diff)) break;
}
for(var index = 0, start = 0;
tmp.match(text)
&& (tmp = tmp.replace(text, ""))
&& index <= diff;
index = start + text.length
) {
start = actual.indexOf(text, index);
}
} else if(obj.selectionStart) {
var start = obj.selectionStart;
var end = obj.selectionEnd;
obj.value = obj.value.substr(0, start)
+ text
+ obj.value.substr(end, obj.value.length);
}
if(start != null) {
setCaretTo(obj, start + text.length);
} else {
obj.value += text;
}
}
function setCaretTo(obj, pos) {
if(obj.createTextRange) {
var range = obj.createTextRange();
range.move('character', pos);
range.select();
} else if(obj.selectionStart) {
obj.focus();
obj.setSelectionRange(pos, pos);
}
}
</script>
</head>
<body>
<form name="form">
<input type="button" value="Insert text" onclick="insertAtCaret(this.form.text,
this.form.string.value)">
<input type="text" name="string"><br />
<textarea name="text" cols="60" rows="10"></textarea>
</form>
</body>
</html>Enquanto o FF usa selectionStart e selectionEnd, o IE usa selection e selection.createRange ... tem umas coisas interessantes pela internet sobre essas funções, embora o exemplo acima seja bem funcional.
In Topic: Mudança De Imagem De Background
04/06/2009, 01:49
Mais um pergunta que só exige pouco conhecimento em javascript e DOM básico. Vou supor que a imagem está dentro de um elemento div, mude de acordo:
<div id="fundo" style="background:#fff;width:250px;height:250px;display:block;"> <a href="#" onclick="this.parentNode.style.backgroundColor='#ff0'">Amarelo</a> <a href="#" onclick="this.parentNode.style.backgroundColor='#f00'">Vermelho</a> </div>
In Topic: Javascript - Mudança De Texto
04/06/2009, 01:40
Simples fazer isso, requer só um pouco de conhecimento em javascript e DOM, ex.:
<a href="#" onclick="this.innerHTML='Galeria 2009'">Clique aqui para mais fotos.</a>
- Fórum WMO
- → Viewing Profile: Posts: bimonti
- Privacy Policy
- Regras ·



Postagens
