Page 1 of 1

any column longest struggle - helper script

Posted: Sun 4. Nov 2007, 15:31
by update
Put into your page's head:

Code: Select all

<script type="text/javascript" src="flod.js"></script>
<script type="text/javascript">
window.onload=function(){
AddFillerLink("content-right","content-left","contentmain-right","contentmain-left","innerbox2-content","navigation-left");
}
</script>
The AddFillerLink (is it an array?) contains the names of your div ids (eg #content-right becomes "content-right" then)
It doesn't work with classes...
Save the following (beeing referenced within page head) as "flod.js"

Code: Select all

//filler text on demand
// http://web-graphics.com/mtarchive/001667.php

var words=new Array("filler","text","silly","very","fill","make","short","long","column","test","dasauchnoch");

function AddFillerLink(){
if(!document.getElementById || !document.createElement) return;
var i,l;
for(i=0;i<arguments.length;i++){
    l=document.createElement("a");
    l.href="#";
    l.appendChild(document.createTextNode("Add Text to this section"));
    l.onclick=function(){AddText(this);return(false)};
    document.getElementById(arguments[i]).appendChild(l);
    }
}

function AddText(el){
var s="",n,i;
n=RandomNumber(200,800);
for(i=0;i<n;i++)
    s+=words[RandomNumber(0,words.length-1)]+" ";
var t=document.createElement("p");
t.appendChild(document.createTextNode(s));
el.parentNode.insertBefore(t,el);
}

function RandomNumber(n1,n2){
return(Math.floor(Math.random()*(n2-n1))+n1);
}
At the top of the script is the source of it :) for further reading.
I find this extremly useful (had a real fight recently to get a construction working but this one has been a real helper :D

claus

Posted: Sun 11. Nov 2007, 14:53
by Heiko H.
Hi claus,

Not bad, not bad!!!

I'm fighting with the same problem at the moment...
But the viewer must have JS enabled... :roll:


THX, Heiko...