In JavaScript, alerts can be created easily using the built-in alert() function. For this first example, an alert is placed directly inside the button tag: <button onclick=”alert(‘I am an alert box!’);”>Example 1</button> Example 1 Here is a more complete example, showing in the HTML context: <!DOCTYPE html> <html> <body> <h2>JavaScript Alert Example 1</h2> <button onclick=”alert(‘I … Continue reading JavaScript: How to create alerts and pop-up windows
Month: October 2017
Python: How to create GUI pop-up windows with Tkinter
When creating a program in Python, a useful thing to be able to do is to have a pop-up window appear on the screen with a special message. This can be used to give instant feedback to the user, alert the user to an error, or inform the user that the program completed successfully. In … Continue reading Python: How to create GUI pop-up windows with Tkinter
JavaScript: Demo of getElementById( )
Here is some JavaScript code that demonstrates how to use JavaScript to change HTML text on a page by clicking a button. When the button is clicked, the text is replaced with a random quote. Reset Demo This example uses DOM elements innerHTML and document.getElementById(). It also uses a couple of Math functions such as … Continue reading JavaScript: Demo of getElementById( )
WordPress: How to create an iframe refresh button
Let’s say you have an interactive canvas loaded in an iframe and you want to have the ability to “clear” the canvas without reloading the entire page. This example was created using p5.js and the html was loaded into an iframe. After drawing on this canvas, it can be cleared by clicking the “Clear Canvas” … Continue reading WordPress: How to create an iframe refresh button
p5.js: Getting Started
Getting started with p5.js, this article follows the instructions found here:https://p5js.org/get-started/ Where processing.py only allows interaction in the Processing code environment, p5.js allows for real time interactive experiences on the web. This article is similar to the previous article I wrote about getting started with Processing.py: In the Processing IDE, choose the p5.js option at … Continue reading p5.js: Getting Started
WordPress: Inject custom CSS to create borders around iframes and images
CSS can be used to style an iframe to give it a border with a drop shadow. For example: Then, in the tag that creates the iframe, reference this CSS using the tag id=”iframe_drop_shadow”. For example: Here is a real working example: An easy way to add the above custom CSS to WordPress is to … Continue reading WordPress: Inject custom CSS to create borders around iframes and images
Python and JavaScript: A comparison of the language basics
In this table I will compare some basic programming syntax and conventions between the Python and JavaScript programming languages. Programming element Python JavaScript Creating a variable that contains an int: age = 25 var age = 25; Creating a variable that contains a float: probability = 0.62 var probability = 0.62; Creating a variable that … Continue reading Python and JavaScript: A comparison of the language basics
Processing.py: How to calculate the midpoint of a line
To calculate the midpoint of a line, use the following formula to calculate the x and y midpoints: # Middle of line # midpoint = (xM, yM) xM = (x1 + x2)/2 yM = (y1 + y2)/2 Then the midpoint coordinates (xM, yM) can be used to draw an ellipse on the line. For example: … Continue reading Processing.py: How to calculate the midpoint of a line
WordPress: How to create a Table of Contents page with Python
What I wanted to create was a dynamic Table of Contents page where I could have a listing of all of my published articles, organized by category, and sorted such that categories with the most posts appear first, and the posts under each category are listed from most recent at the top to oldest at … Continue reading WordPress: How to create a Table of Contents page with Python
WordPress: How to use an iframe to pull in outside content
Here are instructions for using an iframe with wordpress.org websites. 1. Download the iframe Plugin from here. 2. Use a shortcode in a post like this: Note: I added a space after the left bracket [ and before the right bracket ] in order to not trigger the shortcode in the below code example. Summary:Using … Continue reading WordPress: How to use an iframe to pull in outside content