TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,021
  • Total Topics: 21,332
  • Online today: 582
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 238
  • Total: 238

javascript help

Started by Sforzando, November 11, 2006, 02:57:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sforzando

Hi,
    I've been having a lot of trouble with this, so if anyone can help, I'd really, really appreciate it.
I found this really, really cool javascript on another site, put up for anyone to use, but it was put in that "javascript:" short-cut way, where you can just copy/paste the javascript into the url address bar of your browser to see it.


javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++ }setInterval('A()',5); void(0)



what I would like is to actually code it into a page, instead of having to put it in the address bar. So I took out the "javascript:" and put in the language conventions:


<script language="JavaScript">
<!--

R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++ }setInterval('A()',5); void(0)

// -->
</script>



But it didn't work. Could someone tell me, then, how to go from the "javascript:" address bar method to actually coding in a page?
I would really, really appreciate it.
Thanks.

knat

LoL  ;D that looks cool

Cant get it to work in a scrip block  :'(

Sforzando

isn't it though? it's really nice!
If someone knew how to put it in a script block, that would be so awesome. Please!

Thurnok

Well, it looks pretty useless to me, so I'm not sure why you would want to put it in a block, but here, just put this in a phpblock for the same results:

echo '
<script type="text/javascript">
<!--
// set up all vars
R=0;
x1=.1;
y1=.05;
x2=.25;
y2=.24;
x3=1.6;
y3=.24;
x4=300;
y4=200;
x5=300;
y5=200;
// get document.images collection
DI=document.images;
DIL=DI.length;
function A(){
for(i=0; i<DIL; i++){
DIS=DI[ i ].style;
DIS.position="absolute";
DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5;
DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5;
}
R++
}
setInterval("A()",5);
void(0);
// -->
</script>
';
Thurnok
The one, the only!

rebelrose

 :o  That is a bit odd, having that circle around like that. You can also put it in a scriptbox, which is how I looked at it.



<script type="text/javascript">
<!--
// set up all vars
R=0;
x1=.1;
y1=.05;
x2=.25;
y2=.24;
x3=1.6;
y3=.24;
x4=300;
y4=200;
x5=300;
y5=200;
// get document.images collection
DI=document.images;
DIL=DI.length;
function A(){
for(i=0; i<DIL; i++){
DIS=DI[ i ].style;
DIS.position="absolute";
DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5;
DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5;
}
R++
}
setInterval("A()",5);
void(0);
// -->
</script>



Same code as Thurnok but with the echo and the '; removed.

Sforzando

Thanks! But :( I can't get it to work- I tried putting your codes in the head and in the body, but nothing's happening. Here's what I have on the page:



<html>
<head>
<title> blah </title>

</head>
<body>
<script type="text/javascript">
<!--
// set up all vars
R=0;
x1=.1;
y1=.05;
x2=.25;
y2=.24;
x3=1.6;
y3=.24;
x4=300;
y4=200;
x5=300;
y5=200;
// get document.images collection
DI=document.images;
DIL=DI.length;
function A(){
for(i=0; i<DIL; i++){
DIS=DI[ i ].style;
DIS.position="absolute";
DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5;
DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5;
}
R++
}
setInterval("A()",5);
void(0);
// -->
</script>




<img src= "http://www.radu-sirbu.com/mv/d1.gif">
<br />
<img src= "http://www.radu-sirbu.com/mv/d2.gif" width = "80">
<img src= "http://www.radu-sirbu.com/mv/d3.gif" width = "80">
<img src= "http://www.radu-sirbu.com/mv/d4.gif" width = "80">
<img src= "http://www.radu-sirbu.com/mv/d5.gif" width = "80">
<img src= "http://www.radu-sirbu.com/mv/d6.gif" width = "80">
</body>
</html>



and the page is at http://www.radu-sirbu.com/mv/ds.html if you want to see it.

But I don't know why, it's still not working.

Please, I'd appreciate any help. Thanks!

G6Cad

This snippet is for use in a scriptbox, not for putting in your index.template.php

Sforzando

thanks, G6, but what do you mean exactly? Where should it go in order to display on a page? I'm really very ignorant, ugh.

IchBin

We are assuming your using Tinyportal Sforzando?

Sforzando

#9
Yeah, for my forum- http://www.radu-sirbu.com/forum
But I'm asking about an actual page on my site, www.radu-sirbu.com
(actually, I posted this in chit-chat, but it was moved, so I'm not sure if this is the right place, it might be confusing, sorry)
thanks!

This website is proudly hosted on Crocweb Cloud Website Hosting.