(Behind the sillyness – “Don’t click me”)
If you’ve been on my website lately, you may have seen the “don’t click me” pop-up button. If not, here’s what it takes you to. Here’s how to do it, if you’re interested, or just bored an reading the shittiest blog on the net.
Make a button.
First step, is to make a button. You can use <button> for this, here’s some example code for a button.<button onclick="openWindow();">Don't click me</button>
Which brings us to the onclick
element. It tells the browser to do (="WHATEVER();"
) something, when it’s clicked. In this case it will open a pop-up window. Now you must "define
” what “openWindow” does. Here’s how.
We will make a new function. In a .js file, or in the <script>
part of your website document, we will put function openWindow()
. Now to contain the code, we will put { and } around the stuff.
Here’s the code, with messages saying what stuff does. You can remove anything that starts with “//”.
The final code / TL;DR:
function openWindow() var i, l, options = [{
value: ‘first’,
text: ‘First’
}, {
value: ‘second’,
text: ‘Second’
}],
newWindow = window.open(“https://birddev.net/rick.html”, null, “height=200,width=400,status=yes,toolbar=no,menubar=no,location=no”); }
// Replace my page with your URL. Unless you wanna rickroll people too.
function setValue(value)
document.getElementById(‘value’).value = value;
} // Sets the value.
Have fun ^^
– Z
(P.S. this is my first “tutorial” of sorts, and i am also a beginner, so that’s why it kinda sucks.)