Is this script possible with safari???

First off excuse my ignorance, I know nothing about creating applescripts, but I am trying to learn.
What I am trying to do is create a script that will open an mlb.tv page and then select(click) a certain javascript link, which will cause a window to open where a login button needs to be clicked(this step I may be able to do without). Is this posssible … am I off my rocker?

Any help would be greatly appreciated.

Thanks

It is possible. You’ll need to see what the JavaScript code does and use Safari’s Do JavaScript command to run that (leave off the javascript: prefix). The hardest part is waiting to let the popup load before oyu do the next step.

Another useful piece of info: most HTML objects respond to the click() event, so to click a button named checkAddress in a form named myInfo, you’d do this:


tell app "Safari"
  do javscript "document.myInfo.checkAddress,click();" in document 1
end tell

Hope that helps.

Thanks Krioni for your help. The page I am trying to open is http://mlb.mlb.com/NASApp/mlb/mlb/audio/gda/index.jsp. I am able to get that to open. There are several links on the page for selecting different radio stations. The one I want is WPEN and an example javascript for that link is …

javascript:void(playMedia2({r_id:‘323394’,r:‘http://web.servicebureau.net/conf/meta?i=1112453665&c=1234&m=ras’,w_id:‘323395’,w:‘http://web.servicebureau.net/conf/meta?i=1112453665&c=1234&m=was’,pid:%20’mlb_ga’,gid:%20’2004/08/13/sfnmlb-phimlb-1’,cid:%20’phi’,fid:%20’h12’,v:'2’}))

Is there a way to get the applescript to select that javascript link (WPEN) everytime?

The source code from the login page contains this for the login button I think.

<input type="submit" value="Login &" class="btnGreen"

Thanks

Well, is it the same code every time? If so, just put the code (starting with the void part) into the Do Javascript command. If it is different, you’ll have to read the source of the page, or find some other identifier. I assume the letters WPEN are somewhere near that link?

Hmm. No name for the button. That means you’d have to find out which element of the form it is numerically. Is it always, say, the 5th button?