Opened 14 years ago
Closed 14 years ago
#1592 closed defect (wontfix)
around advice on getElementById fails on IE
Reported by: | guest | Owned by: | alex |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | Events | Version: | 0.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
Hi all,
I'm trying to override the getElementById to change the id which is passed to it. (append some dynamic stuff to it).
This works great with the around advice functionality, but only on Firefox and Opera 9. On IE (IE7RC1 or IE6) it fails.
Here is my code:
<script language="JavaScript" type="text/javascript"> <!-- function myGetElementByID(invocation) { var id = invocation.args[0]; if (id.indexOf("-1_VALUE") != -1) { return invocation.proceed(); } if (id.indexOf("_VALUE") != -1) { id = id.substring(0, id.indexOf("_VALUE")); } invocation.args[0] = id + "_-1_VALUE"; try { var result = invocation.proceed(); } catch (e) { alert(e + ""); } return result; } //--> </script>
<script type="text/javascript"> <!-- function init() { dojo.event.connect("around", document, "getElementById", this, "myGetElementByID"); } //dojo.addOnLoad(init); // launch init() function window.onload=new Function('init();'); //--> </script>
IE fails on the line var result = invocation.proceed();
document.getElementById(...) is null or not an object.
Does anyone has an idea how to solve this issue ? (if it solvable :))
Wim
Change History (4)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
I meant:
return invocation.proceed();
but I guess you all know that I meant this :-)
comment:3 Changed 14 years ago by
Milestone: | → 0.5 |
---|---|
Priority: | high → normal |
severity: | critical → major |
comment:4 Changed 14 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
unfortunantly, this isn't something we can fix. It's due to the COM-bound nature of the Document object on IE. You *can* add around advice to dojo.byId(), which is the method you should be using anyway for other reasons. Marking "wontfix".
The try-catch part I copy-pasted is wrong:
It should simply be:
instead of