button6.html:

HTML
<!DOCTYPE html><html><head><title>Button 6</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton6">Button 6</button><script>const button6 = document.getElementById("myButton6");let clickCount6 = 0;button6.addEventListener("click", function() {clickCount6++;if (clickCount6 === 1) {window.open("https://www.example.com/direct-link6", "_blank");} else {window.open("https://www.example.com/main-link6", "_blank");}});</script></body></html>

button7.html:

HTML
<!DOCTYPE html><html><head><title>Button 7</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton7">Button 7</button><script>const button7 = document.getElementById("myButton7");let clickCount7 = 0;button7.addEventListener("click", function() {clickCount7++;if (clickCount7 === 1) {window.open("https://www.example.com/direct-link7", "_blank");} else {window.open("https://www.example.com/main-link7", "_blank");}});</script></body></html>

(and so on for button8 through button15, just incrementing the number in the ID, variable name, and link URLs)

button8.html:

HTML
<!DOCTYPE html><html><head><title>Button 8</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton8">Button 8</button><script>const button8 = document.getElementById("myButton8");let clickCount8 = 0;button8.addEventListener("click", function() {clickCount8++;if (clickCount8 === 1) {window.open("https://www.example.com/direct-link8", "_blank");} else {window.open("https://www.example.com/main-link8", "_blank");}});</script></body></html>

button9.html:

HTML
<!DOCTYPE html><html><head><title>Button 9</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton9">Button 9</button><script>const button9 = document.getElementById("myButton9");let clickCount9 = 0;button9.addEventListener("click", function() {clickCount9++;if (clickCount9 === 1) {window.open("https://www.example.com/direct-link9", "_blank");} else {window.open("https://www.example.com/main-link9", "_blank");}});</script></body></html>

button10.html:

HTML
<!DOCTYPE html><html><head><title>Button 10</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton10">Button 10</button><script>const button10 = document.getElementById("myButton10");let clickCount10 = 0;button10.addEventListener("click", function() {clickCount10++;if (clickCount10 === 1) {window.open("https://www.example.com/direct-link10", "_blank");} else {window.open("https://www.example.com/main-link10", "_blank");}});</script></body></html>

button11.html:

HTML
<!DOCTYPE html><html><head><title>Button 11</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton11">Button 11</button><script>const button11 = document.getElementById("myButton11");let clickCount11 = 0;button11.addEventListener("click", function() {clickCount11++;if (clickCount11 === 1) {window.open("https://www.example.com/direct-link11", "_blank");} else {window.open("https://www.example.com/main-link11", "_blank");}});</script></body></html>

button12.html:

HTML
<!DOCTYPE html><html><head><title>Button 12</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton12">Button 12</button><script>const button12 = document.getElementById("myButton12");let clickCount12 = 0;button12.addEventListener("click", function() {clickCount12++;if (clickCount12 === 1) {window.open("https://www.example.com/direct-link12", "_blank");} else {window.open("https://www.example.com/main-link12", "_blank");}});</script></body></html>

button13.html:

HTML
<!DOCTYPE html><html><head><title>Button 13</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton13">Button 13</button><script>const button13 = document.getElementById("myButton13");let clickCount13 = 0;button13.addEventListener("click", function() {clickCount13++;if (clickCount13 === 1) {window.open("https://www.example.com/direct-link13", "_blank");} else {window.open("https://www.example.com/main-link13", "_blank");}});</script></body></html>

button14.html:

HTML
<!DOCTYPE html><html><head><title>Button 14</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton14">Button 14</button><script>const button14 = document.getElementById("myButton14");let clickCount14 = 0;button14.addEventListener("click", function() {clickCount14++;if (clickCount14 === 1) {window.open("https://www.example.com/direct-link14", "_blank");} else {window.open("https://www.example.com/main-link14", "_blank");}});</script></body></html>

button15.html:

HTML
<!DOCTYPE html><html><head><title>Button 15</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton15">Button 15</button><script>const button15 = document.getElementById("myButton15");let clickCount15 = 0;button15.addEventListener("click", function() {clickCount15++;if (clickCount15 === 1) {window.open("https://www.example.com/direct-link15", "_blank");} else {window.open("https://www.example.com/main-link15", "_blank");}});</script></body></html>

Remember to replace the placeholder URLs (https://www.example.com/...) with your actual links. Also, you can put the CSS in a separate file (e.g., styles.css) and link to it in each HTML file like this: <link rel="stylesheet" href="styles.css"> inside the <head> tag. This is better for organization.


HTML
<!DOCTYPE html>
<html>
<head>
<title>Button 1</title>
<style>  /* Common styles for all buttons */
.myButton {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.myButton:hover {
    background-color: #218838;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.myButton:active {
    background-color: #1e7e34;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    transform: translateY(1px);
}
</style>
</head>
<body>
<button class="myButton" id="myButton1">Button 1</button>
<script>
const button1 = document.getElementById("myButton1");
let clickCount1 = 0; // Important: Each button needs its own click counter

button1.addEventListener("click", function() {
    clickCount1++;

    if (clickCount1 === 1) {
        window.open("https://www.example.com/direct-link1", "_blank");
    } else {
        window.open("https://www.example.com/main-link1", "_blank");
    }
});
</script>
</body>
</html>

button2.html:

HTML
<!DOCTYPE html>
<html>
<head>
<title>Button 2</title>
<style> /* ... (same CSS as above) ... */ </style>
</head>
<body>
<button class="myButton" id="myButton2">Button 2</button>
<script>
const button2 = document.getElementById("myButton2");
let clickCount2 = 0; // Each button needs its own click counter

button2.addEventListener("click", function() {
    clickCount2++;

    if (clickCount2 === 1) {
        window.open("https://www.example.com/direct-link2", "_blank");
    } else {
        window.open("https://www.example.com/main-link2", "_blank");
    }
});
</script>
</body>
</html>

...(and so on for button3.html, button4.html, and button5.html, just changing the ID, variable name, and link URLs in each file). The crucial change is that each button has its own clickCount variable (clickCount1, clickCount2, etc.). This ensures that the click counting is independent for each button.


button16.html:

HTML
<!DOCTYPE html><html><head><title>Button 16</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton16">Button 16</button><script>const button16 = document.getElementById("myButton16");let clickCount16 = 0;button16.addEventListener("click", function() {clickCount16++;if (clickCount16 === 1) {window.open("https://www.example.com/direct-link16", "_blank");} else {window.open("https://www.example.com/main-link16", "_blank");}});</script></body></html>

button17.html:

HTML
<!DOCTYPE html><html><head><title>Button 17</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton17">Button 17</button><script>const button17 = document.getElementById("myButton17");let clickCount17 = 0;button17.addEventListener("click", function() {clickCount17++;if (clickCount17 === 1) {window.open("https://www.example.com/direct-link17", "_blank");} else {window.open("https://www.example.com/main-link17", "_blank");}});</script></body></html>

(and so on for button18 through button30, just incrementing the number in the ID, variable name, and link URLs)

button18.html:

HTML
<!DOCTYPE html><html><head><title>Button 18</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton18">Button 18</button><script>const button18 = document.getElementById("myButton18");let clickCount18 = 0;button18.addEventListener("click", function() {clickCount18++;if (clickCount18 === 1) {window.open("https://www.example.com/direct-link18", "_blank");} else {window.open("https://www.example.com/main-link18", "_blank");}});</script></body></html>

button19.html:

HTML
<!DOCTYPE html><html><head><title>Button 19</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton19">Button 19</button><script>const button19 = document.getElementById("myButton19");let clickCount19 = 0;button19.addEventListener("click", function() {clickCount19++;if (clickCount19 === 1) {window.open("https://www.example.com/direct-link19", "_blank");} else {window.open("https://www.example.com/main-link19", "_blank");}});</script></body></html>

button20.html:

HTML
<!DOCTYPE html><html><head><title>Button 20</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton20">Button 20</button><script>const button20 = document.getElementById("myButton20");let clickCount20 = 0;button20.addEventListener("click", function() {clickCount20++;if (clickCount20 === 1) {window.open("https://www.example.com/direct-link20", "_blank");} else {window.open("https://www.example.com/main-link20", "_blank");}});</script></body></html>

button21.html:

HTML
<!DOCTYPE html><html><head><title>Button 21</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton21">Button 21</button><script>const button21 = document.getElementById("myButton21");let clickCount21 = 0;button21.addEventListener("click", function() {clickCount21++;if (clickCount21 === 1) {window.open("https://www.example.com/direct-link21", "_blank");} else {window.open("https://www.example.com/main-link21", "_blank");}});</script></body></html>

button22.html:

HTML
<!DOCTYPE html><html><head><title>Button 22</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton22">Button 22</button><script>const button22 = document.getElementById("myButton22");let clickCount22 = 0;button22.addEventListener("click", function() {clickCount22++;if (clickCount22 === 1) {window.open("https://www.example.com/direct-link22", "_blank");} else {window.open("https://www.example.com/main-link22", "_blank");}});</script></body></html>

button23.html:

HTML
<!DOCTYPE html><html><head><title>Button 23</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton23">Button 23</button><script>const button23 = document.getElementById("myButton23");let clickCount23 = 0;button23.addEventListener("click", function() {clickCount23++;if (clickCount23 === 1) {window.open("https://www.example.com/direct-link23", "_blank");} else {window.open("https://www.example.com/main-link23", "_blank");}});</script></body></html>

button24.html:

HTML
<!DOCTYPE html><html><head><title>Button 24</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton24">Button 24</button><script>const button24 = document.getElementById("myButton24");let clickCount24 = 0;button24.addEventListener("click", function() {clickCount24++;if (clickCount24 === 1) {window.open("https://www.example.com/direct-link24", "_blank");} else {window.open("https://www.example.com/main-link24", "_blank");}});</script></body></html>

button25.html:

HTML
<!DOCTYPE html><html><head><title>Button 25</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton25">Button 25</button><script>const button25 = document.getElementById("myButton25");let clickCount25 = 0;button25.addEventListener("click", function() {clickCount25++;if (clickCount25 === 1) {window.open("https://www.example.com/direct-link25", "_blank");} else {window.open("https://www.example.com/main-link25", "_blank");}});</script></body></html>

button26.html:

HTML
<!DOCTYPE html><html><head><title>Button 26</title><style> /* ... (same CSS as above) ... */ </style></head><body><button class="myButton" id="myButton26">Button 26</button><script>const button26 = document.getElementById("myButton26");let clickCount26 = 0;button26.addEventListener("click", function() {clickCount26++;if (clickCount26 === 1) {window.open("https://www.example.com/direct-link26", "_blank");} else {window.open("https://www.example.com/main-link26", "_blank");}});</script></body></html>

button27.html:

HTML
<!DOCTYPE html><html><head><title>Button 27</title><style> /* ... (same CSS as above) .

Comments

Popular posts from this blog