Hi @asifshaikhtsn
This is not a WordPress question, so the answers you get from here might not be the right ones for you. Also, please don’t post duplicate topics on the same issue. (https://wordpress.org/support/topic/multiple-links-in-one-website/)
Here’s an adapted javascript snippet that might help you. It’s not the best – I just customized your given code.
<script>
var links=new Array(); var i=0;
links[0]="http://facebook.com";
links[1]="http://gmail.com"
links[2]="http://yahoo.com";
links[3]="http://cnn.com";
links[4]="http://www.geocities.com";
/* add as many links as you want */
function getmenextlink(){
window.open(links[i%links.length]);
i++; }
</script>
<input type="button" value="Button" onclick="getmenextlink()">
Keep in mind that some browsers prevent javascript from opening multiple windows. This needs further testing.
Hope this helps,
Kind regards!
Thank You So Much @vladytimy i’ll Hope your code will be work for me but i m totally new in wordpress that’s why i don’t know much about it so can you please help me..
i want to know that where i need to add this code …
thank you one again @vladytimy
Again, this might not be the best approach, but I’m following with your initial code.
Install and activate this plugin: https://wordpress.org/plugins/insert-headers-and-footers/ Go to Dashboard > Settings > Insert Headers and Footers > Scripts in Footer and paste this code:
<script>
var links=new Array()
var i=0;
links[0]="http://facebook.com";
links[1]="http://gmail.com"
links[2]="http://yahoo.com";
links[3]="http://cnn.com";
links[4]="http://www.geocities.com";
function getmenextlink(){
window.open(links[i%links.length]);
i++;
}
</script>
Then, in your Post/Page Editor/Widgets, add the Custom HTML block and put in it:
<input type="button" value="Click me now!" onclick="getmenextlink()">
You might want to style your button based on your preferences.
If so, add in Dashboard – Appereance – Customize – Additional CSS in the Customizer your desired css styling. For example:
input[type=button] {
background-color: #4CAF50;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
font-weight:500;
border:solid 2px #087d13;
box-shadow: 4px 4px 10px #888888;
}
You can learn how to use the Chrome Developer Tools or Firefox Developer Tools to help you see and test changes to your CSS.
Maybe someone else here has another better solution from the start.
Hope this helps,
Kind regards!
whatever you done for me that’s all is very very mean for me and thank you soo much for helping me very much. May God Bless you. Thankh You Soo Much