html5 - javascript variable not working inside html tag -


i want html attribute values javascript statement(function). marks portion block red on image targeted co-ordinates inside area tag. full code given below @ bottom.

this works fine:

<script type="text/javascript">     document.write('<area href="#" select="red" shape="rect" coords="69,76,84,102">'); </script> 

but reason reason, not seem work. ideas?

<script type="text/javascript">   var crd=[69,76,84,102];   document.write('<area href="#" select="red" shape="rect" coords="'+crd[0]+","+crd[1]+","+crd[2]+","+crd[3]+'">'); </script>  

this html file.

    <!doctype html>     <html>     <head>     <title>mapping physical library</title>     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>     <script src="scripts/jquery.imagemapster.js"></script>      </head>      <body>      <img id="pic" src="unnamed.png" usemap="#mark">     <script>     $(document).ready(function ()     {         $('#pic').mapster({             singleselect : true,             mapkey: 'select',             fill : true,             fillcolor : 'ff0000',             fillopacity : 1,             areas : [{key : 'red', selected : true}]         });     });     </script>      <map name="mark">         <script type="text/javascript">             document.write('<area href="#" select="red" shape="rect" coords="69,76,84,102">');         </script>            </map>     </body>     </html> 

    document.write('<area href="#" select="red" shape="rect" coords="'+crd[0]+"','"+crd[1]+"','"+crd[2]+"','"+crd[3]+'">'); 

you missed sing quot in comma(,)

or try

document.write('<area href="#" select="red" shape="rect" coords="'+ crd.join(",")+'">'); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -