start an html file, give it a title and header, then save it

29
Using an HTML image (img) element’s onclick event to change the source (src) of an iframe to an embedded youtube video

Upload: kathy

Post on 13-Jan-2016

24 views

Category:

Documents


0 download

DESCRIPTION

Using an HTML image (img) element’s onclick event to change the source (src) of an iframe to an embedded youtube video. Start an HTML file, give it a title and header, then Save it. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Start an HTML file, give it a title and header, then Save it

Using an HTML image (img) element’s onclick event to change the source (src) of an iframe to an embedded youtube video

Page 2: Start an HTML file, give it a title and header, then Save it

Start an HTML file, give it a title and header, then Save it.

Page 3: Start an HTML file, give it a title and header, then Save it

Navigate to http://www.lasalle.edu/~blum/c230wks/abraham.gif, right click on image and save to same location as HTML file

Page 4: Start an HTML file, give it a title and header, then Save it

Repeat for http://www.lasalle.edu/~blum/c230wks/martin.gif

Page 5: Start an HTML file, give it a title and header, then Save it

Go to Design tab (at the bottom) and click on Table on the menu, choose Insert Table

Page 6: Start an HTML file, give it a title and header, then Save it

Using the Insert Table dialog, choose 2 rows and 2 columns and click OK.

Page 7: Start an HTML file, give it a title and header, then Save it

Return to the Source view tab.

Notice the open and close table tags <table> and </table>.

Notice the open and close table row tags <tr> and </tr> -- there are two sets because there are two rows.

Notice the open and close table data (cell) tags <td> and </td> -- -- there are four sets because there are four cells (two rows with two columns each).

Page 8: Start an HTML file, give it a title and header, then Save it

&nbsp;

• The HTML code &nbsp; stands for a non-breaking space• Spaces in HTML code do not always translate into spaces seen by the

user (person looking at the page), but the code &nbsp; does correspond to a space seen by the user• http://w3schools.com/html/html_entities.asp• http://en.wikipedia.org/wiki/Non-breaking_space

Page 9: Start an HTML file, give it a title and header, then Save it

Drag from the Image icon in the Toolbox to between the first open cell and close cell tags

Remember that if you do not have the Toolbox, you can get it by going to View/Toolbox on the menu

Page 10: Start an HTML file, give it a title and header, then Save it

Click on the image so it appears in in the Properties Window on the left. Scroll to the src property (attribute) and click on the ellipsis (…) button that appears after you click in the cell next to src

Remember that if you don’t have the Properties Window, you can get it by going to View/Properties Window on the menu. (Properties Window is near the bottom of the list.)

Page 11: Start an HTML file, give it a title and header, then Save it

Use the dialog to select the abraham.gif file and click OK.

It is really convenient when you are just starting to make webpages to put the image file and HTML file in the same location.

Page 12: Start an HTML file, give it a title and header, then Save it

See the result – and remember you can always just type the code provided you know it.

Page 13: Start an HTML file, give it a title and header, then Save it

Repeat for the second cell which should have an img element with the martin.gif file as its source.

Page 14: Start an HTML file, give it a title and header, then Save it

Go to File/View in Browser to see the result so far

Page 15: Start an HTML file, give it a title and header, then Save it

Next we Googled “html youtube” and choose the w3schools link (third).

Page 16: Start an HTML file, give it a title and header, then Save it

Copy example code from http://www.w3schools.com/html/html_youtube.asp

Page 17: Start an HTML file, give it a title and header, then Save it

Paste the code between the open cell <td> and close cell </td> tags for both cells in the second row of the table

Page 18: Start an HTML file, give it a title and header, then Save it

Result so far

Page 19: Start an HTML file, give it a title and header, then Save it

Search youtube for a video on the Gettysburg Address and pick one.

Page 20: Start an HTML file, give it a title and header, then Save it

We want the video’s code which appears after the ?v= in the URL

Page 21: Start an HTML file, give it a title and header, then Save it

Paste the copied video code after the embed/ in the src attribute of the iframe

Page 22: Start an HTML file, give it a title and header, then Save it

Result so far.

Page 23: Start an HTML file, give it a title and header, then Save it

Repeat for the “I have a dream speech.” <iframe width="420" height="345" src="http://www.youtube.com/embed/smEqnnklfYs"></iframe>

Page 24: Start an HTML file, give it a title and header, then Save it

Result so far

Page 25: Start an HTML file, give it a title and header, then Save it

Give the Lincoln image an onclick event: <img alt="" src="abraham.gif" onclick="return Abe()" />• And add the corresponding script section and function to the head.

Page 26: Start an HTML file, give it a title and header, then Save it

Give the Abraham iframe an id attribute (ifAbe)

Page 27: Start an HTML file, give it a title and header, then Save it

Add the code document.getElementById("ifAbe").src = "http://www.youtube.com/embed/_Dlggkx6mks";

to your function. Make the src of the iframe equal to “”

Page 28: Start an HTML file, give it a title and header, then Save it

The effect is to eliminate the iframe src (youtube video) until the image is clicked.

Page 29: Start an HTML file, give it a title and header, then Save it

Repeat for Martin: give iframe an id, give image an onclick, write function to handle onclick