Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't grab a DOM node using parentNode in IE 7/8
    primarykey
    data
    text
    <p>i am working on an adapted version of <a href="http://code.google.com/p/imgmap/" rel="nofollow">Adam Maschek's excellent image map tool</a>. The new functionality i have added are left/top/width/height input boxes so that you can have pixel control over the hotspot position/size. I have got it working fine in FF and Chrome but the issue i am having is in IE 7/8 where it just will not retrieve the value of the input box on change.</p> <p>Here is the function where the issue is occuring:</p> <pre><code>function gui_dimension_change(e) { function changeAreaPos(areaNum, inputVal, cssAttrib, coordPos) { var coordsBox = document.getElementsByClassName('img_coords')[areaNum], newCoordsVal = coordsBox.value.split(","), newWidth = "", newHeight = "", imCode = imcodeContainer.value, pattern = imCode.match(/\d+,\d+,\d+,\d+/g); myimgmap.areas[areaNum].style[cssAttrib] = inputVal; if (cssAttrib === "left" || cssAttrib === "top") { myimgmap.areas[areaNum].label.style[cssAttrib] = inputVal; newCoordsVal[coordPos] = inputVal; } else if (cssAttrib === "width") { myimgmap.areas[areaNum].width = inputVal; newWidth = parseInt(newCoordsVal[0]) + parseInt(inputVal); newCoordsVal[coordPos] = newWidth; } else if (cssAttrib === "height") { myimgmap.areas[areaNum].height = inputVal; newHeight = parseInt(newCoordsVal[1]) + parseInt(inputVal); newCoordsVal[coordPos] = newHeight; } newCoordsVal = newCoordsVal.join(","); myimgmap.areas[areaNum].lastInput = newCoordsVal; coordsBox.value = newCoordsVal; imCode = imCode.replace(pattern[areaNum], newCoordsVal); imcodeContainer.value = imCode; }; // alert(this); // alert(this.parentNode); // alert(this.parentNode.id); var inputParent = this.parentNode, inputVal = this.value, whichBox = this.name, areaNum = inputParent.id.replace("img_area_", ""), imcodeContainer = document.getElementById('html_container'); switch(whichBox) { case "img_left": changeAreaPos(areaNum, inputVal, "left", 0); break; case "img_top": changeAreaPos(areaNum, inputVal, "top", 1); break; case "img_width": changeAreaPos(areaNum, inputVal, "width", 2); break; case "img_height": changeAreaPos(areaNum, inputVal, "height", 3); break; } } </code></pre> <p>The function is called like so:</p> <pre><code>myimgmap.addEvent(props[id].getElementsByTagName('input')[5], 'change', gui_dimension_change); myimgmap.addEvent(props[id].getElementsByTagName('input')[6], 'change', gui_dimension_change); myimgmap.addEvent(props[id].getElementsByTagName('input')[7], 'change', gui_dimension_change); myimgmap.addEvent(props[id].getElementsByTagName('input')[8], 'change', gui_dimension_change); </code></pre> <p>So on the change event i can't set inputParent with this.parentNode, and can't grab the value of the input box with this.value either. Works in FF/Chrome but not IE 7/8, any ideas why IE has a problem with parentNode and getting the value?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload