Hi i'm trying to make a script that opens a random link from the page contained in an iframe after 5 seconds ....a sort of random redirection that's what i done : <head></head><body> <script> <!-- function random_all(){ var myrandom=Math.round(Math.random()*(document.links.length-1)) window.location=document.links[myrandom].href } //--> </script> <a href="javascript:random_all()">Random Link</a> <iframe id="frame" frameborder="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" width="100%" height="100%" src="http://www.yahoo.com"> </iframe> </body> Thanks for your help
You want the links from inside the iframe, not the links from the current document. Give a name to that iframe (name="frame"), and instead of "document.links", use top.frames['frame'].document.links. Also, use setTimeout to call your function every 5 seconds