Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

shaking word

Posted on 2009-07-07
6
Medium Priority
?
301 Views
Last Modified: 2012-05-07
hi....

can anyone please give me right code for shaking these 'hello world' while i put the mouse over it!

find the code below please!

thank you

<html>
hello world
</html>

Open in new window

0
Comment
Question by:ferman-k
  • 2
  • 2
  • 2
6 Comments
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24794642
hi ferman-k,

                  Follow the step by step procedure in the given below link and it will display shaking text in the browser.

Shaking Text  :

http://www.hypergurl.com/shakingtext.html


Thanks.

Tapan Pattaniak
0
 
LVL 12

Expert Comment

by:Chad Haney
ID: 24797961
Here is a simple example
<html>
<head>
<script type="text/javascript">
var go=true;
var left = true;
var shakeMe;
function shakeText(doIt, who){
	go=doIt;
	shakeMe=who;
	shake();
}
function shake(){
	if(go){
		var pos = shakeMe.style.left;
		pos = pos.substring(0,pos.indexOf("px"));
		if (left){
			shakeMe.style.left = parseInt(pos) + 1;
			left=false;	
		}else{
			shakeMe.style.left = parseInt(pos) - 1;	
			left=true;
		}
		var t = setTimeout("shake()",50);
	}
}
</script>
</head>
<body>
<span style="position:relative;left:0;" onmouseover="shakeText(true, this)" onmouseout="shakeText(false, this)">Hello</span>
</body>
</html>

Open in new window

0
 

Author Comment

by:ferman-k
ID: 24798560
i have used same code you sent and the hello word was not makng any move at all.. what do you think the problem might be? please!

please find the included code

<html>
<head>
<script type="text/javascript">
var go=true;
var left = true;
var shakeMe;
function shakeText(doIt, who){
        go=doIt;
        shakeMe=who;
        shake();
}
function shake(){
        if(go){
                var pos = shakeMe.style.left;
                pos = pos.substring(0,pos.indexOf("px"));
                if (left){
                        shakeMe.style.left = parseInt(pos) + 1;
                        left=false;     
                }else{
                        shakeMe.style.left = parseInt(pos) - 1; 
                        left=true;
                }
                var t = setTimeout("shake()",50);
        }
}
</script>
</head>
<body>
<span style="position:relative;left:0;" onmouseover="shakeText(true, this)" onmouseout="shakeText(false, this)">Hello</span>
</body>
</html>

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Accepted Solution

by:
Tapan Pattanaik earned 2000 total points
ID: 24798900
hi ferman-k,

                     
Check this code, which will display shaking "hello word"

Thanks.


 <script type="text/javascript" >
//configure message
message="Hello word"
//animate text in NS6? (0 will turn it off)
ns6switch=1
 
var ns6=document.getElementById&&!document.all
mes=new Array();
mes[0]=-1;
mes[1]=-4;
mes[2]=-7;mes[3]=-10;
mes[4]=-7;
mes[5]=-4;
mes[6]=-1;
num=0;
num2=0;
txt="";
function jump0(){
if (ns6&&!ns6switch){
jump.innerHTML=message
return
}
if(message.length > 6){
for(i=0; i != message.length;i++){
txt=txt+"<span style='position:relative;' id='n"+i+"'>"+message.charAt(i)+"</span>"};
jump.innerHTML=txt;
txt="";
jump1a()
}
else{
alert("Your message is to short")
}
}
 
function jump1a(){
nfinal=(document.getElementById)? document.getElementById("n0") : document.all.n0
nfinal.style.left=-num2;
if(num2 != 9){
num2=num2+3;
setTimeout("jump1a()",50)
}
else{
jump1b()
}
}
 
function jump1b(){
nfinal.style.left=-num2;
if(num2 != 0){num2=num2-3;
setTimeout("jump1b()",50)
}
else{
jump2()
}
}
 
function jump2(){
txt="";
for(i=0;i != message.length;i++){
if(i+num > -1 && i+num < 7){
txt=txt+"<span style='position:relative;top:"+mes[i+num]+"'>"+message.charAt(i)+"</span>"
}
else{txt=txt+"<span>"+message.charAt(i)+"</span>"}
}
jump.innerHTML=txt;
txt="";
if(num != (-message.length)){
num--;
setTimeout("jump2()",50)}
else{num=0;
setTimeout("jump0()",50)}}
</script>
 
 
<div id="jumpx" style="color:green"></div>
<script type="text/javascript">
if (document.all||document.getElementById){
jump=(document.getElementById)? document.getElementById("jumpx") : document.all.jumpx
jump0()
}
else
document.write(message)
</script>

Open in new window

0
 
LVL 12

Expert Comment

by:Chad Haney
ID: 24798922
Did you have position defined as either absolute or relative and left defined?
0
 

Author Closing Comment

by:ferman-k
ID: 31600606
in fact it was not what i wanted, but i consider it better,, the word is not shaking, it wiggling instead, which it lovely and i like more. ;-)

i appreciate your guide, thank you
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question