-
Replace:
Code:
<style>
.shakeimage{
position:relative
}
</style>
<script language='JavaScript1.2'>
<![CDATA[
/*
Shake image script (onMouseover)-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
//configure shake degree (where larger # equals greater shake)
var rector=3
///////DONE EDITTING///////////
var stopit=0
var a=1
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
]]>
</script>
with (there are many changes, I think I've highlighted them all, just copy the below and replace the above on your page with it):
Code:
<style type="text/css">
.shakeimage{
position:relative
}
</style>
<script type="text/javascript">
<!--[CDATA[
/*
Shake image script (onMouseover)-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
//configure shake degree (where larger # equals greater shake)
var rector=3
///////DONE EDITTING///////////
var stopit=0
var a=1
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector+'px';
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector+'px';
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector+'px';
}
else{
shake.style.left=parseInt(shake.style.left)-rector+'px';
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
// ]]-->
</script>
It will make the J shake when you move your mouse over the J.
-
-
You killed all the line breaks in the script:
Code:
<style type='text/css'>
.shakeimage{
position:relative
}
</style>
<script type='text/javascript'>
<!--[CDATA[ /* Shake image script (onMouseover)- © Dynamic Drive (www.dynamicdrive.com) For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com */ //configure shake degree (where larger # equals greater shake) var rector=3 ///////DONE EDITTING/////////// var stopit=0 var a=1 function init(which){ stopit=0 shake=which shake.style.left=0 shake.style.top=0 } function rattleimage(){ if ((!document.all&&!document.getElementById)||stopit==1) return if (a==1){ shake.style.top=parseInt(shake.style.top)+rector+'px'; } else if (a==2){ shake.style.left=parseInt(shake.style.left)+rector+'px'; } else if (a==3){ shake.style.top=parseInt(shake.style.top)-rector+'px'; } else{ shake.style.left=parseInt(shake.style.left)-rector+'px'; } if (a<4) a++ else a=1 setTimeout("rattleimage()",50) } function stoprattle(which){ stopit=1 which.style.left=0 which.style.top=0 } // ]]-->
</script>
Start over with what I actually posted, make sure your editor doesn't strip out the line breaks in the script.
-
Sorry. It was purposely done since the original copy gave the same warning sign. forgot to replace it back with the one you provided.
-
wait a sec. When i selected the view source, the line breaks dissappeared though I'm really sure to have copy paste exactly the same script you gave. hmm.. I should figure out why.
-
Ok John. probably the error caused by the missing line breaks. I saved the view source data to a new html file, opened it in a new browser and paste your modified script into it and refreshed. Amazingly the letter J shaked!! I dunno why the line breaks dissappeared from the original site or how to repair it.
-
Fortunately, a script can be all one line if it is written to be that way. This version of the script (I'm not including the style, keep that as it was) should work regardless of line breaks:
Code:
<script type="text/javascript">
<!--[CDATA[
/*
Shake image script (onMouseover)-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
/* configure shake degree (where larger # equals greater shake) */
var rector=3;
/* ///////DONE EDITTING/////////// */
var stopit=0;
var a=1;
function init(which){
stopit=0;
shake=which;
shake.style.left=0;
shake.style.top=0;
};
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return;
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector+'px';
};
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector+'px';
};
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector+'px';
};
else{
shake.style.left=parseInt(shake.style.left)-rector+'px';
};
if (a<4)
a++;
else
a=1;
setTimeout("rattleimage()",50);
};
function stoprattle(which){
stopit=1;
which.style.left=0;
which.style.top=0;
};
// ]]-->
</script>
-
Please, please, please do tell me if I've missed any part of your help http://smileys.smileycentral.com/cat/36/36_1_44.gif
-
Calm down. I'm not sure what the problem is with your editor. But I did overreach with my most recent solution. I'm sorry about that. As far as I can tell, you need to find a way to paste in the correct code without losing the line breaks (from post #11 in this thread):
Code:
<style type="text/css">
.shakeimage{
position:relative
}
</style>
<script type="text/javascript">
<!--[CDATA[
/*
Shake image script (onMouseover)-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
//configure shake degree (where larger # equals greater shake)
var rector=3
///////DONE EDITTING///////////
var stopit=0
var a=1
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector+'px';
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector+'px';
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector+'px';
}
else{
shake.style.left=parseInt(shake.style.left)-rector+'px';
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
// ]]-->
</script>
You might be able to make it an external file. But before we mess around with that, what editor are you using?
-
I'm using blogger.com. not sure whether this answer your question.:confused: