Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2008
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question a popular injection image placement modification problem

    okay so im sure everybody knows of the code that makes images fly around....
    Code:
    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.getElementsByTagName("img"); 
    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)+"px";
    DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"
    }
    R++
    }setInterval('A()',5);
    void(0);
    well i thought in order to do something similar i should understand this more so i thought about just mocing the pictures to on place on the screen like the top left corner or something after about an hour of looking at and testing parts of this code i go to...
    Code:
    javascript:DI=document.getElementsByTagName("img");DI.left=26+"px"; DI.top=25+"px";
    yet it still doesnt work but merely displays 25px in the top left is there anything else that will get all images into the top left hand corner or a modified version of this script. NOTE: all of this must be placed in the adress bar for javascript injection on any page.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by jhouns View Post
    Code:
    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.getElementsByTagName("img"); 
    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)+"px";
    DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"
    }
    R++
    }setInterval('A()',5);
    void(0);
    Code:
    javascript:DI=document.getElementsByTagName("img");DI.left=26+"px"; DI.top=25+"px";
    document.getElementsByTagName returns a node-list and setting the left and top of a node-list ain't gonna move the images anywhere. If you notice the code that you posted, you will notice that they are iterating through every item in the node-list and setting the left and top of the image's style object.
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • Users who have thanked shyam for this post:

    jhouns (08-31-2008)

  • #3
    New Coder
    Join Date
    Aug 2008
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts
    ahh right i get where i was wrong now thanks for all the help correct thanks to you


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •