1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Attribute String Test</title>
6
7
14
15 <style>
16 code {
17 font-size: 1.2em ;
18
19 font-weight: bold ;
20 }
21 </style>
22
23 </head>
24
25 <body>
26
27 <p><em>This text appears before the image.</em></p>
28 <img id="cover" src="..\PRO_Manual\Graphics\pro cover.jpg" width=200>
29 <p><em>This text appears after the image.</em></p>
30
31
32 <p>The image above is being displayed by the HTML code:</p>
33 <blockquote>
34 <code><img id="cover" src="..\PRO_Manual\Graphics\pro cover.jpg" width=200></code></p>
35 </blockquote>
36
37
38 <p id="message"></p>
39
40 <script>
41
42 var elemImg = document.getElementById( "cover" ) ;
43
44 var imgWidth = elemImg.getAttribute( "width" ) ;
45
46 console.log( "typeof imgWidth = " + typeof imgWidth ) ;
47 console.log( "imgWidth + imgWidth = " + ( imgWidth + imgWidth ) ) ;
48 console.log( "eval(imgWidth) + eval(imgWidth) = " + ( eval(imgWidth) + eval(imgWidth) ) ) ;
49
50
51 var elemMsg = document.getElementById( "message" ) ;
52
53 elemMsg.innerHTML =
54 "<code>img </code>attribute<code> width </code> is of " +
55 "type:<code> " + typeof imgWidth + "<br>" +
56 "imgWidth + imgWidth = " + ( imgWidth + imgWidth ) + "<br>" +
57 "eval(imgWidth) + eval(imgWidth) = " + ( eval(imgWidth) + eval(imgWidth) ) +
58 "</code>" ;
59 ;
60 </script>
61 </body>
62
63 </html>