Web Analytics Made Easy -
StatCounter Auto load links - CodingForum

Announcement

Collapse
No announcement yet.

Auto load links

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Auto load links

    I have a list of about 150 links(which can change daily), I need a way to make them automaticly load one by one every 20 seconds or so in a frame on my site. I asked a couple people that I know and they said it could probably be done in javascript but they didn't know how to do it. Does anyone know how to do this?

  • #2
    something like this?:
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    <
    script type="text/javascript">
    var 
    delay 20000;//in milliseconds
    var links=[]
    links[0] =['google','http://www.google.com'];
    links[1] =['yahoo','http://www.yahoo.com'];
    links[2] =['altavista','http://www.altavista.com'];
    var 
    i=0;
    function 
    linkdel(){
    var 
    root=document.getElementById('mydiv');
    var 
    oA document.createElement('a');
    oA.setAttribute('href',links[i][1]);
    oA.appendChild(document.createTextNode(links[i][0]));
    var 
    oBr document.createElement('br');
    root.appendChild(oA);
    root.appendChild(oBr);
    i++;
    var 
    check =(i==links.length)?clearTimeout(check):setTimeout('linkdel()',delay);
    }
    onload=linkdel;
    </
    script>

    </
    head>
    <
    body>
    <
    div id="mydiv"></div>
    </
    body>
    </
    html
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

    Comment


    • #3
      When I said load, I mean I need the link needs to be opened in a frame.

      Code:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
      <html>
      <head>
      <title>Links</title>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <LINK REL=stylesheet HREF="hl.css" TYPE="text/css">
      </head>
      
      <frameset cols="25%,75%">
         <frame src="lists.html" name="list">
         <frame src="side.html" name="side">
      </frameset>
      <noframes><body>
      </body></noframes>
      </html>
      I need to have the links open up in the "side" frame.

      Comment


      • #4
        put the code in that frame
        KOR
        Offshore programming
        -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

        Comment


        • #5
          Originally posted by Kor
          put the code in that frame
          I tried that code, it just makes the links appear. I need something that will open the links in the other frame. Again, when I say open and load I mean like when you click on a link.

          Comment


          • #6
            *bump*

            Comment


            • #7
              Put this at the head of the frameset page.
              Code:
              <script type="text/javascript">
                var delay = 20000;//in milliseconds
                var links=['http://www.google.com',
                              'http://www.yahoo.com',
                              'http://www.altavista.com' //no comma at the last link
                             ];
                function autoOpen(idx){
                   if (idx<links.length){
                     var w = window.open(links[i], "side");
                     w.focus();
                     setTimeout(function(){ autoOpen(++idx) }, delay);
                   }
              }
              window.onload=function(){ autoOpen(0); };
              </script>
              But why are you loading the pages automatically?
              The user may be annoyed by this.
              Glenn
              vBulletin Mods That Rock!

              Comment

              Working...
              X