KyleKJune Posted July 30, 2009 Share Posted July 30, 2009 hi i want to make a javascript that will redirect the user who clicked the link to a random page on my website. i have found ways to do it but none work in internet explorer. internet explore restricts activex from running.is there a way to make a webpage that will redirect the person who goes to it to a random one of the websites below each time they go to the webpage and work in internet explorer?www.exuad.tkwww.meomb.tkwww.venep.tkwww.keell.tkwww.neign.tkwww.holae.tkwww.hygre.tkwww.mudsu.tkwww.enjoh.tkwww.lockn.tkwww.swipu.tkwww.tizep.tkwww.emenc.tkwww.nonve.tkwww.powdu.tkwww.snomy.tkwww.subda.tkwww.hynid.tkwww.cruct.tkwww.osist.tk Link to comment Share on other sites More sharing options...
dsonesuk Posted July 30, 2009 Share Posted July 30, 2009 (edited) store addresses in array, then run JavaScript random number generator to produce a number, retrieve address relating to random number, and add that address to the to link.var myArrayname = new Array('addr1','addr2','addr3');ORvar myArrayname = new Array();myArrayname[0] = "addr1";myArrayname[1] = "addr2";myArrayname[2] = "addr3";var myArrayRef = Math.ceil(Math.random() * myArrayname.length-1)document.getElementById('myAnchor').href=myArrayname[myArrayRef]; Edited July 30, 2009 by dsonesuk Link to comment Share on other sites More sharing options...
KyleKJune Posted July 30, 2009 Author Share Posted July 30, 2009 store addresses in array, then run JavaScript random number generator to produce a number, retrieve address relating to random number, and add that address to the to link.var myArrayname = new Array('addr1','addr2','addr3');ORvar myArrayname = new Array();myArrayname[0] = "addr1";myArrayname[1] = "addr2";myArrayname[2] = "addr3";var myArrayRef = Math.ceil(Math.random() * myArrayname.length-1)document.getElementById('myAnchor').href=myArrayname[myArrayRef];i tried those. it wont work in IE. IE shows an error about activex saying its unsafe and they wont load it. Link to comment Share on other sites More sharing options...
jeffman Posted July 30, 2009 Share Posted July 30, 2009 Nothing that dsonesuk showed you uses an activeX object. You should not even need an activeX object to change a page's location. You'd better show how you're implementing this stuff. Post some code. Link to comment Share on other sites More sharing options...
boen_robot Posted July 30, 2009 Share Posted July 30, 2009 Are you sure you aren't testing on your own computer? Put your testing file on an HTTP server, and run it from there. It should work with no warnings. If it still does (or it doesn't work), post your code. Link to comment Share on other sites More sharing options...
KyleKJune Posted July 30, 2009 Author Share Posted July 30, 2009 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><title>home</title><meta http-equiv="Content-type" content="text/html;charset=UTF-8"></head><body><script type="text/javascript">var myArrayname = new Array();myArrayname[0] = "http://www.exuad.tk";myArrayname[1] = "http://www.venep.tk";myArrayname[2] = "http://www.neign.tk";myArrayname[3] = "http://www.hygre.tk";myArrayname[4] = "http://www.enjoh.tk";myArrayname[5] = "http://www.swipu.tk";myArrayname[6] = "http://www.emenc.tk";myArrayname[7] = "http://www.powdu.tk";myArrayname[8] = "http://www.subda.tk";myArrayname[9] = "http://www.cruct.tk";myArrayname[10] = "http://www.meomb.tk";myArrayname[11] = "http://www.keell.tk";myArrayname[12] = "http://www.holae.tk";myArrayname[13] = "http://www.mudsu.tk";myArrayname[14] = "http://www.lockn.tk";myArrayname[15] = "http://www.tizep.tk";myArrayname[16] = "http://www.nonve.tk";myArrayname[17] = "http://www.snomy.tk";myArrayname[18] = "http://www.hynid.tk";myArrayname[19] = "http://www.osist.tk";var myArrayRef = Math.ceil(Math.random() * myArrayname.length-1)document.getElementById('myAnchor').href=myArrayname[myArrayRef]; </script></body></html>this code above is not working in any browser. Link to comment Share on other sites More sharing options...
boen_robot Posted July 30, 2009 Share Posted July 30, 2009 You need to actually have an anchor with ID "myAnchor" for this to work.Add this right between <body> and <script>: <a id="myAnchor" href="">Redirect...</a> You could also (instead and/or in addition to this) try to add: window.location = myArrayname[myArrayRef]; Right before the script ends. Link to comment Share on other sites More sharing options...
dsonesuk Posted July 30, 2009 Share Posted July 30, 2009 (edited) put javascript code within function, run this function onload ie window.onload=runthisfunction; (outside of function) move this code to the head.add <a href="#" id="myAnchor">Click this random link</a> to body<head><script type="text/javascript">function runthisfunction(){random link code}window.onload=runthisfunction;</script></head><body><a href="#" id="myAnchor">Click this random link</a></body Edited July 30, 2009 by dsonesuk Link to comment Share on other sites More sharing options...
KyleKJune Posted July 30, 2009 Author Share Posted July 30, 2009 thanks for your help everyone. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now