PDA

View Full Version : Opening multiple links



LifeIsBeta
11-03-2006, 04:18 PM
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!

jscheuer1
11-04-2006, 06:25 AM
Where do you want the links opened? I'm thinking in frames or in iframes would be best. What did you have in mind?

LifeIsBeta
11-04-2006, 01:08 PM
yeah, iFrames seemed to me the easiest way.

jscheuer1
11-04-2006, 05:22 PM
A bare bones approach:


<!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.