Useful Javascript commands

Discussions and Tech Support specific to the iMacros Firefox Add-on.
Forum rules
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
Volodath
Posts: 23
Joined: Mon Jan 17, 2011 11:32 pm

Useful Javascript commands

Post by Volodath » Thu May 12, 2011 10:34 pm

Hello All -

Knowing that this community has a treasure of greater programming knowledge than I currently posses, I'm hoping I could get helps on a hurdle I have to get past to bring my current scripts up to where I want them. They're not critical things, but the value and ease that they add would certainly be very appreciated.

Is there a javascript command to view only a particular frame of a website? I've heard it mentioned that you can use URL GOTO just to go to that URL but (and I feel sheepish saying this) I haven't found a reliable way to do that; I don't know how to extract the URL of a frame, and the URL changes every time the script is run. If I could even extract the frame url and then use URL GOTO to navigate to only that frame, that would work out handily

Thanks in advance.

Volo
Tom, Tech Support
Posts: 3545
Joined: Mon May 31, 2010 4:59 pm

Re: Useful Javascript commands

Post by Tom, Tech Support » Sat May 14, 2011 4:00 pm

Hello Volodath,

Here is one way to do it. This example uses the iMacros Frames demo page. The actual solution will depend on how the frames are coded in the source HTML of the page(s) you are working with.

Code: Select all

URL GOTO=http://www.iopus.com/imacros/demo/v5/frames/index.htm         
TAG POS=1 TYPE=FRAME ATTR=NAME:main2 EXTRACT=HREF
URL GOTO={{!EXTRACT}}
Regards,

Tom, iMacros Support
Volodath
Posts: 23
Joined: Mon Jan 17, 2011 11:32 pm

Re: Useful Javascript commands

Post by Volodath » Tue May 17, 2011 5:47 pm

Tom -

Thanks for the response. I'd previously tried to extract using EXTRACT=HREF but hadn't been able to get anywhere. The site I'm attempting to automate is proprietary, so I can't like up directly, but here's a snippet of the HTML.


Code: Select all

<frameset framespacing="0" border="0" frameborder="0" rows="73,*">
<frame scrolling="no" marginheight="0"" marginwidth="0" name="top" src="/scripts/***.htm,EN">
<frame marginheight="0" marginwidth="0" name="main" src="/scripts/***.htm,NON-ACCOUNTING" style="border-color: rgb(0, 0, 255); border-width: 2px; border-style: solid;">
<html>
<head>
<frameset border="0" cols="158,*">
<frame scrolling="auto" name="sidebar" noresize="" marginheight="0" marginwidth="0" src="https://ssl.*/*/*/*?41,29,01GT0YKAOI,sidebar.htm">
<frame scrolling="auto" name="certificate" noresize="" marginheight="0" marginwidth="0" src="https://ssl.*/*/*/*,0013086302">

I've tried the following code to extract the 4th frame (certificate) but I haven't been able to get anywhere.

TAG POS=1 TYPE=FRAME ATTR=NAME:* EXTRACT=HREF
on positions 1,2,3 and 4 , and also
TAG POS=1 TYPE=FRAME ATTR=NAME:certificate EXTRACT=HREF

Either command works for frames 1 and 2 (main and top)

Where did I go wrong? If necessary I can run this in the iMacros Browser with scripting but I'd prefer to keep it in firefox.
Tom, Tech Support
Posts: 3545
Joined: Mon May 31, 2010 4:59 pm

Re: Useful Javascript commands

Post by Tom, Tech Support » Tue May 24, 2011 6:40 pm

Hi Volodath,

Sorry, I haven't got a clue why it isn't working, your TAG commands look good.

You might also want to consider using the SEARCH command with a regular expression to extract the desired text. The SEARCH command searches the source HTML.
Regards,

Tom, iMacros Support
Volodath
Posts: 23
Joined: Mon Jan 17, 2011 11:32 pm

Re: Useful Javascript commands

Post by Volodath » Thu Jul 07, 2011 5:53 pm

So just an update here with more information. I haven't been able to solve the above problem, but other things have come up on that project so it's not a big deal.

On the project that's superseded this one however, I have come across the same situation, but I've noticed something that I missed before. On this frame (it's a frame of <PRE> text I'm trying to save) I get this data from the frame info:

Referring URL: https://*Private*Website*/Blah/blah/blah/pageflow/*.jsp?refNumberIndex=0

While the address of the actual document is

https://*Private*Website*/Blah/blah/blah/type=txt&index=0&convert=jpeg

Using the HREF extraction mentioned above gets me the referring URL, but if I manually find the second URL and go to that url directly I'm able to successfully save only that page as a .HTM or .PNG

Is there any command that would auto-extract the second url?
Tom, Tech Support
Posts: 3545
Joined: Mon May 31, 2010 4:59 pm

Re: Useful Javascript commands

Post by Tom, Tech Support » Mon Jul 18, 2011 11:11 am

Volodath wrote:So just an update here with more information. I haven't been able to solve the above problem, but other things have come up on that project so it's not a big deal.

On the project that's superseded this one however, I have come across the same situation, but I've noticed something that I missed before. On this frame (it's a frame of <PRE> text I'm trying to save) I get this data from the frame info:

Referring URL: https://*Private*Website*/Blah/blah/blah/pageflow/*.jsp?refNumberIndex=0

While the address of the actual document is

https://*Private*Website*/Blah/blah/blah/type=txt&index=0&convert=jpeg

Using the HREF extraction mentioned above gets me the referring URL, but if I manually find the second URL and go to that url directly I'm able to successfully save only that page as a .HTM or .PNG

Is there any command that would auto-extract the second url?
Sorry Volodath, I am not following you on this one. I don't fully understand the situation from your description.
Regards,

Tom, iMacros Support
Post Reply