Results 1 to 4 of 4

Thread: Opening multiple links

  1. #1
    Join Date
    Aug 2006
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Opening multiple links

    Hey all,

    I have several unordered lists of links. I'd like to place one link above each list that would basically open all the links in THAT list one by one. How can I put this in a js function, so it's portable enough to be able to apply it to any unordered list on my site?

    Thanks!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Where do you want the links opened? I'm thinking in frames or in iframes would be best. What did you have in mind?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2006
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yeah, iFrames seemed to me the easiest way.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    A bare bones approach:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    .dframe {
    width:500px;
    height:400px;
    margin:20px 20px 0 0;
    }
    </style>
    <script type="text/javascript">
    onload=function(){
    var c=0, ilists=[];
    var lists=document.getElementsByTagName('ul');
    for (var i_tem = 0; i_tem < lists.length; i_tem++)
    if ( lists[i_tem].className=='inframe' )
    ilists[c++]=lists[i_tem];
    for (i_tem = 0; i_tem < ilists.length; i_tem++)
    for (var j_tem = 0; j_tem < ilists[i_tem].getElementsByTagName('li').length; j_tem++)
    if (ilists[i_tem].getElementsByTagName('li')[j_tem].getElementsByTagName('a')[0]){
    var lframe=document.createElement('iframe');
    lframe.className='dframe';
    lframe.src=ilists[i_tem].getElementsByTagName('li')[j_tem].getElementsByTagName('a')[0].href
    document.body.appendChild(lframe);
    }
    }
    </script>
    </head>
    <body>
    <ul class="inframe">
    <li><a href="http://www.dynamicdrive.com/">dynamic drive</a></li>
    <li><a href="http://www.google.com/">google</a></li>
    <li><a href="http://www.codingforums.com/">coding forums</a></li>
    <li><a href="http://www.yahoo.com/">yahoo</a></li>
    <li>no link</li>
    </ul>
    </body>
    </html>
    If a division is made or is available, the iframes could be made to appear in it, other things could be done but, this is basic code for doing this.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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