EVAL and window/document objects

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
lanx
Posts: 38
Joined: Sat Jul 03, 2010 2:11 am

EVAL and window/document objects

Post by lanx » Wed Jul 27, 2016 1:55 am

Hi, I'm getting crazy trying to collect attributes, values and ids from any page using EVAL command.

This simple code works with no hassle while launched as a bookmarklet

Code: Select all

javascript:(function(){x=window.content.document.title;alert(x)})();
but...

Code: Select all

SET !VAR9 EVAL("var x=window.content.document.title;x")
... the same code inside a macro always lead to a ReferenceError: window is not defined

Are there any limitations in EVAL interactions with document elements and their retrieval using javascript methods like .querySelector() or getElementById() ??
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: EVAL and window/document objects

Post by iimfun » Wed Jul 27, 2016 11:33 am

Some notes as to the 'EVAL' command ( http://wiki.imacros.net/EVAL ):
The code evaluation occurs in an execution context that is separate from the browser process, therefore access to the web page DOM is not available.
and
For DOM/GUI access you can use URL GOTO with Javascript.
And, of course, this may be helpful to you as well:
http://wiki.imacros.net/FAQ#Q:_How_to_a ... Javascript
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL and window/document objects

Post by chivracq » Thu Apr 20, 2017 8:37 am

lanx wrote:Hi, I'm getting crazy trying to collect attributes, values and ids from any page using EVAL command.

This simple code works with no hassle while launched as a bookmarklet

Code: Select all

javascript:(function(){x=window.content.document.title;alert(x)})();
but...

Code: Select all

SET !VAR9 EVAL("var x=window.content.document.title;x")
... the same code inside a macro always lead to a ReferenceError: window is not defined

Are there any limitations in EVAL interactions with document elements and their retrieval using javascript methods like .querySelector() or getElementById() ??
iimfun wrote:Some notes as to the 'EVAL' command ( http://wiki.imacros.net/EVAL ):
The code evaluation occurs in an execution context that is separate from the browser process, therefore access to the web page DOM is not available.
and
For DOM/GUI access you can use URL GOTO with Javascript.
And, of course, this may be helpful to you as well:
http://wiki.imacros.net/FAQ#Q:_How_to_a ... Javascript
Hum, @lanx, I just saw you Online right now and I thought you were going to open some new Thread but nope..., ah-ah...! :D

But hum, I guess I was bored so I had a look at your last Threads, and hum-hum-hum..., I'm not too impressed...! :shock: , they all lack you mentioning your FCI and they all lack some Follow-up from your Side to finish them a bit correctly with a Solution shared from your Side if you managed to solve them or a mini-Thanks for other (Advanced) Users who tried to help you...

This current Thread is a perfect BAD Example, grrr...!!!, FCI not mentioned (Reason very probably why I didn't react at that time, you got a bit "lucky" with @iimfun who's "nicer" than me...), while I would have a much simpler Solution to your Qt, nearly surprised you didn't find it (OK, just tested it (on iMacros for FF v8.8.2, PM v26.3.3 (=FF47), Win10-x64) and it works indeed...), or that @iimfun didn't post it, and if you found it, you should have posted it spontaneously to help other Users, but pfff, same thing actually for all few previous Threads from you I checked...
=> Could you improve a bit on "that" for this current Thread and all those previous Threads...?
This one is already nearly one year old, next time you'll be having a "real" Pb and could really use some Help from the Forum, I will first ask you to finish those Threads correctly, and you'll have to wait for the same amount of time before eventually bumping your Thread one year later for me to give you the/a Solution, oops...! :twisted:
=> If I were you, I would take "proactive" Measures to avoid "that", just saying... :idea:
And yep, I'm being ironic with "proactive"..., I shouldn't have to ask... :roll:

But OK, ignore my Post if you get offended (not my Intention, I mean it well, just trying to make all Threads useful with a Solution for other Users searching the Forum...), but I had a very simple Solution for you for this current Thread, that you would have gotten as soon as I had noticed your Thread at that time when you had opened it...
But sorry, I only help Users using the Forum a bit "correctly"..., and [FCI mentioned + neat Follow-up + Sharing their Solution (for all their Threads of course...!)] are a few of my "Criteria"... :oops: I am sometimes a bit "flexible" for first-time-posters on the Forum, but joined the Forum 7 years ago, that doesn't apply to you anymore, ah-ah...! You should have had the time at least to read the Forum Rules I would think..., and Follow-up is a matter of "Etiquette"...
Last edited by chivracq on Mon Jun 04, 2018 10:50 am, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
lanx
Posts: 38
Joined: Sat Jul 03, 2010 2:11 am

Re: EVAL and window/document objects

Post by lanx » Tue Apr 25, 2017 11:18 am

Hi chivracq,

you're right and I want to express my most sincere apologies: I should have paid more attention to such matters but, believe me, it hasn't been intentional. :oops:

In most cases I have found a proper solution or a tricky workaround by myself, or I have simply dropped a project after many headaches without checking new incoming replies to my threads, which usually came after many days or didn't came at all. :cry:

Sorry: I'll try to be more polite and grateful... and no: I'm not offended at all because you're just right and you have explained the whole concept really kindly.

On the other hand, if you are a moderator and such advanced forum user you claim to be, you should know that a private message for these strictly personal matters is much more suitable: "Etiquette" is also made of this (who am I to disagree... I traveled the world and the seven seas... everybody's looking for something). :wink:

Anyway... please accept once again my most sincere apologies.

Regarding this thread, I really don't remember anymore what I was trying to do but, as far as I can guess, it should be something that I gave up.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL and window/document objects

Post by chivracq » Tue Apr 25, 2017 4:17 pm

lanx wrote:Hi chivracq,

you're right and I want to express my most sincere apologies: I should have paid more attention to such matters but, believe me, it hasn't been intentional. :oops:

In most cases I have found a proper solution or a tricky workaround by myself, or I have simply dropped a project after many headaches without checking new incoming replies to my threads, which usually came after many days or didn't came at all. :cry:

Sorry: I'll try to be more polite and grateful... and no: I'm not offended at all because you're just right and you have explained the whole concept really kindly.

On the other hand, if you are a moderator and such advanced forum user you claim to be, you should know that a private message for these strictly personal matters is much more suitable: "Etiquette" is also made of this (who am I to disagree... I traveled the world and the seven seas... everybody's looking for something). :wink:

Anyway... please accept once again my most sincere apologies.

Regarding this thread, I really don't remember anymore what I was trying to do but, as far as I can guess, it should be something that I gave up.
Ah-ah...!, good-good... Hum, even if FCI (Full Config Info about your Environment) is still not mentioned...

Well, PM is disabled on the Forum, I guess deliberately by the Forum Admin, hum..., could be an Idea to ask if they can enable it by Default, even if I fear I will have to disable it quickly for myself, ah-ah...!
My "Role" as Mod is mostly to approve first-time Posters to prevent Spam and Duplicate Threads and sometimes Threads opened in the "wrong" Sub-Forum.

For this current Thread and what you were trying to do, you don't need to be very "Advanced User", ah-ah...!, the Solution I had in mind is fairly simple:

Code: Select all

TAG POS=1 TYPE=TITLE ATTR=* EXTRACT=TXT
PROMPT {{!EXTRACT}}
(Tested on iMacros for FF v8.8.2, PM v26.3.3 (=FF47), Win10-x64.)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
lanx
Posts: 38
Joined: Sat Jul 03, 2010 2:11 am

Re: EVAL and window/document objects

Post by lanx » Tue Apr 25, 2017 11:42 pm

chivracq wrote: Ah-ah...!, good-good... Hum, even if FCI (Full Config Info about your Environment) is still not mentioned...
FCIM= iMacros for FF 8.9.7, Firefox x64 53.0, Windows 10 x64 (1703 build 15063.138)
chivracq wrote: For this current Thread and what you were trying to do, you don't need to be very "Advanced User", ah-ah...!, the Solution I had in mind is fairly simple:

Code: Select all

TAG POS=1 TYPE=TITLE ATTR=* EXTRACT=TXT
PROMPT {{!EXTRACT}}
(Tested on iMacros for FF v8.8.2, PM v26.3.3 (=FF47), Win10-x64.)
Ooooh... now I remember!! It was such a noob question that when I found the solution (the same one you have just recommended here) I felt like a complete idiot :lol: :lol:
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL and window/document objects

Post by chivracq » Wed Apr 26, 2017 1:16 am

lanx wrote:
chivracq wrote: Ah-ah...!, good-good... Hum, even if FCI (Full Config Info about your Environment) is still not mentioned...
FCIM=

Code: Select all

iMacros for FF  8.9.7, Firefox x64 53.0, Windows 10 x64 (1703 build 15063.138)
chivracq wrote: For this current Thread and what you were trying to do, you don't need to be very "Advanced User", ah-ah...!, the Solution I had in mind is fairly simple:

Code: Select all

TAG POS=1 TYPE=TITLE ATTR=* EXTRACT=TXT
PROMPT {{!EXTRACT}}
(Tested on iMacros for FF v8.8.2, PM v26.3.3 (=FF47), Win10-x64.)
Ooooh... now I remember!! It was such a noob question that when I found the solution (the same one you have just recommended here) I felt like a complete idiot :lol: :lol:
Well, noob-noob-noob, if you registered 7 years ago on the Forum, and must have been using iMacros for at least 7 years, realize that if you have some Qt after 6-7 years using iMacros, you'll definitely won't be the only/first one having the same Qt..., and sharing your Solution is always useful for other Users...

Thanks for mentioning your FCI, even if it's your current FCI (April 2017) (and not the one you had in July 2016 when you opened the Thread...!, which is the one you should have mentioned for this Thread...), but still useful, as you are the first User mentioning/confirming that v8.9.7 (still) works on FF53... We already had one User a few days ago mentioning using FF53, but it was not completely clear if they were using v9.0.3 or v8.9.7...! :D
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply