-2

I am working on image mapster, but when I do the following I get NaN for coords.

<div id="rts" class="largWin"><a href="a.html" class="close">&times;</a>

<center><img id="floo-map1" src="img/plan.jpg" alt="Floor plan in Pan Pacific Level 4" border="0" width="750" height="472"  usemap="#floorplan-conference-map1" style="width:750px; height:472px;"/></center>
<map id="image_map1" name="floo-map1">
<script>
  function getx()
  {
    return 425,78,483,116 ;
  }
</script>
<area id = "try" name="gg" full="ggh" shape="rect" coords=getx() href="#">
</map>
</div>

How can I fix it?

clami219
  • 2,958
  • 1
  • 31
  • 45
Charu
  • 9
  • 1
    I don't know much about imagemapster, but 425,78,483,116 is not a number. I don't know if it's looking for an array but there is clearly something wrong with that – Surreal Jul 20 '17 at 13:10

1 Answers1

0

Thats not how javascript works. you dont return its value to area thats why you getting NaN because coords is not getting anyvalues.

instead change the values inside the getx()

 document.getElementById("try").coords = "425,78,483,116";

But why do you want to change its coords in javascript to begin with?

Or try Try coords="return getx()"

  • I need the coords to be changing dynamically – Charu Jul 20 '17 at 13:13
  • Try coords="return getx()" –  Jul 20 '17 at 13:14
  • @anand if you want the coords to change, you need to "push" the coords (e.g. document.getElementById("try").coords = "425,78,483,116") *whenever* you want them to change, the area object won't "pull" the updated data. You can't simply name a function in the coord attribute and expect it to be called, you need to make the update yourself - usually either on a timer or when the source data changes. – Peteris Jul 20 '17 at 13:21