PDA

View Full Version : Help With Text On Web Page



hungrylilboy
04-08-2004, 11:01 AM
If i put the following into the head section of my webpage it should make the selected text tremble. I have got it working before. Could someone look at it and tell me what i have done wrong this time as it aint working! :helpsmile:

This bit in head section>>>>>>


<style>
.jc{
position:relative;
}
</style>

&#60;script language="JavaScript1.2">

var ns6=document.getElementById&&&#33;document.all
var ie=document.all

var customcollect=new Array()
var i=0

function jiggleit(num){
if ((&#33;document.all&&&#33;document.getElementById)) return;
customcollect[num].style.left=(parseInt(customcollect[num].style.left)==-1)? customcollect[num].style.left=1 : customcollect[num].style.left=-1
}

function init(){
if (ie){
while (eval("document.all.jiggle"+i)&#33;=null){
customcollect[i]= eval("document.all.jiggle"+i)
i++
}
}
else if (ns6){
while (document.getElementById("jiggle"+i)&#33;=null){
customcollect[i]= document.getElementById("jiggle"+i)
i++
}
}

if (customcollect.length==1)
setInterval("jiggleit(0)",80)
else if (customcollect.length>1)
for (y=0;y<customcollect.length;y++){
var tempvariable=&#39;setInterval("jiggleit(&#39;+y+&#39;)",&#39;+&#39;100)&#39;
eval(tempvariable)
}
}

window.onload=init

</script>


And then this bit around the text>>>>


<span id="jiggle1" class="jc">inserted text</span>

Cl1mh4224rd
04-08-2004, 12:46 PM
I don&#39;t see any semicolons in that JavaScript code... There should be a semicolon at the end of most of those line.

Try this:


&#60;script language=&#34;JavaScript1.2&#34;&#62;

var ns6=document.getElementById&&&#33;document.all;
var ie=document.all;

var customcollect=new Array&#40;&#41;;
var i=0;

function jiggleit&#40;num&#41; {
&nbsp; &nbsp;if &#40;&#40;&#33;document.all&&&#33;document.getElementById&#41;&#41; return;
&nbsp; &nbsp;customcollect&#91;num&#93;.style.left=&#40;parseInt&#40;customcollect&#91;num&#93;.style.left&#41;==-1&#41;? customcollect&#91;num&#93;.style.left=1 &#58; customcollect&#91;num&#93;.style.left=-1;
}

function init&#40;&#41; {
&nbsp; &nbsp;if &#40;ie&#41; {
&nbsp; &nbsp; &nbsp; &nbsp;while &#40;eval&#40;&#34;document.all.jiggle&#34;+i&#41;&#33;=null&#41; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;customcollect&#91;i&#93;= eval&#40;&#34;document.all.jiggle&#34;+i&#41;;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;i++;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
&nbsp; &nbsp;else if &#40;ns6&#41; {
&nbsp; &nbsp; &nbsp; &nbsp;while &#40;document.getElementById&#40;&#34;jiggle&#34;+i&#41;&#33;=null&#41; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;customcollect&#91;i&#93;= document.getElementById&#40;&#34;jiggle&#34;+i&#41;;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;i++;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}

&nbsp; &nbsp;if &#40;customcollect.length==1&#41; {
&nbsp; &nbsp; &nbsp; &nbsp;setInterval&#40;&#34;jiggleit&#40;0&#41;&#34;,80&#41;;
&nbsp; &nbsp;}
&nbsp; &nbsp;else if &#40;customcollect.length&#62;1&#41; {
&nbsp; &nbsp; &nbsp; &nbsp;for &#40;y=0;y&#60;customcollect.length;y++&#41; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var tempvariable=&#39;setInterval&#40;&#34;jiggleit&#40;&#39;+y+&#39;&#41;&#34;,&#39;+&#39;100&#41;&#39;;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;eval&#40;tempvariable&#41;;
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
}

window.onload=init;

&#60;/script&#62;

hungrylilboy
04-08-2004, 02:06 PM
Originally posted by Cl1mh4224rd@8 April 2004 - 12:46
if ((&#33;document.all&&&#33;document.getElementById)) return;
customcollect[num].style.left=(parseInt(customcollect[num].style.left)==-1)? customcollect[num].style.left=1 : customcollect[num].style.left=-1;
}
*************here***********
function init() {
if (ie) {
while (eval("document.all.jiggle"+i)&#33;=null) {

still doesnt work.
comes up with an error when u try to preview it which says that it expects a &#39;)&#39; in the place where i have mark stars

johannes001
04-08-2004, 08:29 PM
HEAD:


&#60;style&#62;
.jc{
position&#58;relative;
}
&#60;/style&#62;

&#60;script language=&#34;JavaScript1.2&#34;&#62;

var ns6=document.getElementById&&&#33;document.all
var ie=document.all

var customcollect=new Array&#40;&#41;
var i=0

function jiggleit&#40;num&#41;{
if &#40;&#40;&#33;document.all&&&#33;document.getElementById&#41;&#41; return;
customcollect&#91;num&#93;.style.left=&#40;parseInt&#40;customcollect&#91;num&#93;.style.left&#41;==-1&#41;? customcollect&#91;num&#93;.style.left=1 &#58; customcollect&#91;num&#93;.style.left=-1
}

function init&#40;&#41;{
if &#40;ie&#41;{
while &#40;eval&#40;&#34;document.all.jiggle&#34;+i&#41;&#33;=null&#41;{
customcollect&#91;i&#93;= eval&#40;&#34;document.all.jiggle&#34;+i&#41;
i++
}
}
else if &#40;ns6&#41;{
while &#40;document.getElementById&#40;&#34;jiggle&#34;+i&#41;&#33;=null&#41;{
customcollect&#91;i&#93;= document.getElementById&#40;&#34;jiggle&#34;+i&#41;
i++
}
}

if &#40;customcollect.length==1&#41;
setInterval&#40;&#34;jiggleit&#40;0&#41;&#34;,80&#41;
else if &#40;customcollect.length&#62;1&#41;
for &#40;y=0;y&#60;customcollect.length;y++&#41;{
var tempvariable=&#39;setInterval&#40;&#34;jiggleit&#40;&#39;+y+&#39;&#41;&#34;,&#39;+&#39;100&#41;&#39;
eval&#40;tempvariable&#41;
}
}

window.onload=init

&#60;/script&#62;


BODY:


&#60;span id=&#34;jiggle0&#34; class=&#34;jc&#34;&#62;&#60;b&#62;text&#60;/a&#62;&#60;/b&#62;&#60;/span&#62;


straight from the source SOURCE (http://www.dynamicdrive.com/dynamicindex10/tremble.htm) <_<

hungrylilboy
04-08-2004, 09:40 PM
did u try it? cos i couldnt get it to work

johannes001
04-08-2004, 10:16 PM
Ooops , all that acting smart and got the code wrong myself :ph34r: .

I&#39;ve put in an extra </a> when copying from the original :rolleyes:


HEAD SHOULD BE:

&#60;span id=&#34;jiggle0&#34; class=&#34;jc&#34;&#62;&#60;b&#62;text&#60;/b&#62;&#60;/span&#62;