For years we wrote gross regular expressions to get query string values but those days are gone—enter the amazing URLSearchParams API: // Assuming "?post=1234&action=edit" var urlParams = new URLSearchParams(window.location.search); console.log(urlParams.has('post')); // true console.log(urlParams.get('action'));...
Want to retrieve a unique array of values from an array that may include duplicate values? You can use new JavaScript spread operator with Set to get an array of unique values: var j = […new Set([1, 2, 3, 3])] >> [1, 2, 3] Retrieving unique values from an array with JavaScript.
Choosing your jQuery Plugin This is a crucial decision that will be reflected in the outcome of your carousel, especially if you have a video player included on your slides. A very popular jQuery plugin that I usually use is Cycle Plugin; however, after including a video and testing it on all browsers I found that there is a critical issue with...
Im trying to load a variable for five you tube videos to randomly grab one as a variable and display it on pageload <scrypt> var vtube=new Array() vtube[0]='UT000008' vtube[1]='UT000008' vtube[2]='UT000008' vtube[3]='UT000008' vtube[4]='UT000008' ...
There are many, many different computer programming languages in use today. Each has its own set of special features, which are highly praised by its fans and vigorously panned by its detractors. If you have worked in more than one language then you are aware that there is a continuum of language styles, ranging from highly structured languages...
Written by GentleGiant on 06/29/12 at 14:07:18 EST
There is a third way for a while loop to terminate. If the special statement break is encountered inside the while block, the loop is forced to terminate immediately. No further statements are executed and the condstmt is not retested. Execution continues with the first statement after the end of the while block. Listing 2.4 gives an example of...
Written by GentleGiant on 06/29/12 at 14:07:11 EST
Listing 2.4 A while Loop with an Internal break Statement var x = 1; var xoddsum = 0; var xtmp = 0; var lastx = 0; while ( true ) { // 1: loop forever (well, almost) xtmp = xoddsum + x; // 2: compute a trial sum if ( xtmp > 100 ) // 3: if it is too...
Written by GentleGiant on 06/29/12 at 14:07:01 EST
There is another special statement that may be used inside while loops: the continue statement. The continue statement is used to force the flow of control back to the top of the while loop. When a continue statement is seen, all statements between it and the end of the while block are skipped, and execution continues at the top of the while....
Written by GentleGiant on 06/29/12 at 14:06:53 EST
The basic statements, expressions, and operators that were discussed at the beginning of this chapter are what computer scientists usually call primitives. Primitives are the building blocks from which more complex elements of a program are constructed. The for, while, and if control structures represent the next higher level of organization in...
Written by GentleGiant on 06/29/12 at 14:06:43 EST
A common task for CSS is to center text or images. In fact, there are three kinds of centering: Centering lines of text The most common and (therefore) easiest type of centering is that of lines of text in a paragraph or in a heading. CSS has the property 'text-align' for that: P { text-align: center } H2 { text-align: center } renders...
To scale a YouTube video to fit any browser or tablet/mobile device for responsive design you can use either a CSS or Javascript solution to accomplish the goal. This example uses a CSS solution, you need to add a couple of CSS styles in your main CSS file. The first thing that you need is the YouTube iframe embed code, grab that in your video...
The fieldset element is a convenient way to create groups of widgets that share the same purpose, for styling and semantic purposes. You can label a fieldset by including a legend element just below the opening fieldset tag. The text content of the legend formally describes the purpose of the fieldset it is included inside. Many assistive...