Jump to content

DHTML structure access - square brackets use


Recommended Posts

Hello.

I have noticed I cannot access object properties by using square bracket notation (javascript) - is there any reason for that? I was unable to find it in AutoIt documentation.

For example:

$oBrowser1.window.frames['gnrl_src'].window.frames['pg_src'].frames['main_src'].name

doesn't work: Error parsing function call.

while "incorrect" (javascript/DHTML) syntax works:

$oBrowser1.window.frames('gnrl_src').window.frames('pg_src').frames('main_src').name

Dot notation works fine too...

$oBrowser1.window.frames.gnrl_src.window.frames.pg_src.frames.main_src.name
Link to comment
Share on other sites

Hi and Welcome to the forums!!

I'm afraid I don't really understand your question. This is AutoIt, not Javascript. Square brackets just isn't part of our syntax.

Link to comment
Share on other sites

You can 'eval' a quoted string using the Javascript syntax rules, otherwise you must use AutoIt syntax because it is AutoIt that is walking the object hierarchy.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Thanks (not surprisingly I have been lurking around for a while).

Yes, I understand that the AutoIt syntax is different from Javascript.

But since dot notation was usable, and basically most of DOM 'syntax' was also functional (even possible to just copy&paste), I wondered why square brackets do not work - and I haven't found anything in help/wiki. Basically I have discovered that ('xxx') works instead of ['xxx'] only by trial and error. Reasons for my question were curiosity and need for clarification.

So, do I understand it correctly, that square brackets are to be used only for arrays in AutoIT? And in Web Browser DOM (or elsewhere) round brackets are to be used instead (in places of square ones)?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...