Skip to main content
1-Visitor
January 25, 2017
Solved

getElementsByClassName

  • January 25, 2017
  • 1 reply
  • 1867 views

I am trying to select same elements with different parents that have the same class using getElementsByClassName, but i get the following error message:

org.mozilla.javascript.EcmaError: TypeError: Cannot find function getElementsByClassName in object com.arbortext.epic.internal.aom.DocumentImpl@156d16c0. (C:\program files\ptc\arbortext editor\custom\scripts\Local.js#3985)

    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3689)

    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3667)

    at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3695)

    at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3714)

    at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3786)

    at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2268)

    at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2250)

    at org.mozilla.javascript.gen.C__program_files_ptc_arbortext_editor_custom_scripts_Local_js_25._c_Renumber_32(C:\program files\ptc\arbortext editor\custom\scripts\Local.js:3985)

    at org.mozilla.javascript.gen.C__program_files_ptc_arbortext_editor_custom_scripts_Local_js_25.call(C:\program files\ptc\arbortext editor\custom\scripts\Local.js)

    at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)

    at org.mozilla.javascript.gen.C__program_files_ptc_arbortext_editor_custom_scripts_Local_js_25._c_InsertStep_14(C:\program files\ptc\arbortext editor\custom\scripts\Local.js:1228)

    at org.mozilla.javascript.gen.C__program_files_ptc_arbortext_editor_custom_scripts_Local_js_25.call(C:\program files\ptc\arbortext editor\custom\scripts\Local.js)

    at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)

    at org.mozilla.javascript.gen.C__program_files_ptc_arbortext_editor_custom_scripts_Local_js_25._c_InsertElements_11(C:\program files\ptc\arbortext editor\custom\scripts\Local.js:316)

    at org.mozilla.javascript.gen.C__program_files_ptc_arbortext_editor_custom_scripts_Local_js_25.call(C:\program files\ptc\arbortext editor\custom\scripts\Local.js)

    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)

    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3090)

    at org.mozilla.javascript.gen.C__program_files_ptc_arbortext_editor_custom_scripts_Local_js_25.call(C:\program files\ptc\arbortext editor\custom\scripts\Local.js)

    at org.mozilla.javascript.JavaAdapter.doCall(JavaAdapter.java:606)

    at org.mozilla.javascript.JavaAdapter.access$000(JavaAdapter.java:15)

    at org.mozilla.javascript.JavaAdapter$1.run(JavaAdapter.java:586)

    at org.mozilla.javascript.Context.call(Context.java:489)

    at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:504)

    at org.mozilla.javascript.JavaAdapter.callMethod(JavaAdapter.java:583)

    at adapter2.handleEvent(<adapter>)

Any idea why getElementsByClassName cannot by found? How would I get getElementsByClassName to work?

Thank you for help!

Have a blessed day!

Florin

Best answer by ClayHelberg

Hi Florin--

Document.getElementsByClassName() is a DOM level 4 function, but Arbortext's AOM is based on DOM level 2. So that function is not available in Arbortext.

You may be able to accomplish what you need with the ADocument.getElementsByAttribute() (or getElementsByAttributeNS(), if you are using namespaces).

--Clay

1 reply

18-Opal
January 25, 2017

Hi Florin--

Document.getElementsByClassName() is a DOM level 4 function, but Arbortext's AOM is based on DOM level 2. So that function is not available in Arbortext.

You may be able to accomplish what you need with the ADocument.getElementsByAttribute() (or getElementsByAttributeNS(), if you are using namespaces).

--Clay

otudor1-VisitorAuthor
1-Visitor
January 27, 2017

Thank you Clay! That worked fine for me.

I wonder when PTC would migrate its AOM to DOM level 4 since DOM level 2 is almost 7-8 years old?

18-Opal
January 27, 2017

You could propose it as a "Product Idea" and see what kind of response you get from PTC.