How to call Javascript functions on websites

Share your tips, tricks and favorite iMacros macros, scripts and applications for web automation in general here.

Moderator: iMacros Moderators

How to call Javascript functions on websites

by Tech Support on Wed Dec 19, 2007 4:13 am

You can use the URL GOTO command to execute Javascript functions on websites. If you do this, please remember to replace space " " with "<SP>".

Example: A simple Javascript bookmarklet to count links:

Code: Select all
javascript:if(frames.length<1){alert('This page has'+document.links.length+' links.')}else{alert('The page has frames!')}

After you replace " " with "<SP>" the command looks like:

Code: Select all
URL GOTO=javascript:if(frames.length<1){alert('This<SP>page<SP>has<SP>'+document.links.length+'<SP>links.')}else{alert('The<SP>page<SP>has<SP>frames!')}
User avatar
Tech Support
Posts: 5003
Joined: Tue Sep 20, 2005 12:25 pm

Re: How to call Javascript functions on websites

by crfutu on Thu Mar 12, 2009 7:57 am

it's helpful
Posts: 10
Joined: Fri Oct 17, 2008 1:08 am

Re: How to call Javascript functions on websites

by danieljph on Mon Nov 16, 2009 6:26 pm

Dear Tech Support,

Is it possible to pass the document.links.length var onto test.js when it is executed from within iimPlay("CODE:...")? Executing the document.links.length if/else from within test.js returns "The page has frames!" which I believe might be due to the iMacros sidebar. Thanks in advance.
Posts: 5
Joined: Mon Nov 16, 2009 5:57 pm

Return to How-To's and useful iMacros: All other topics

Who is online

Users browsing this forum: No registered users and 2 guests