0

im creating a random link href button, i want to make button that can go to different ID.

<a href="#comment">this one is working</a>

function randomlinks(){
    var myrandom=Math.round(Math.random()*2)
    var links=new Array()
    links[0]="#commentsection"
    links[1]="/#commentsection"
    links[2]="http://www.example.com/#commentsection"

 
    window.location=links[myrandom]
}
<form>
<input type="button" value="Random ID" onClick="randomlinks()">
</form>
Reivax
  • 125
  • 1
  • 6
  • What is not working? – kiranvj Dec 01 '17 at 07:39
  • im trying to make href button go to ID, example when i click the button it goes to #Div1, but the code above reload my page and show link not found. – Reivax Dec 01 '17 at 07:42
  • @Reivax Your example doesn't go to three different fragment identifiers, but to the same fragment identifiers in three different URLs. – Mr Lister Dec 01 '17 at 08:52

0 Answers0