Java Script Command or Applescript error?

Discussion in 'Mac Programming' started by thriftinkid, Feb 4, 2009.

  1. macrumors regular

    Joined:
    Mar 24, 2008
    #1
    Hey Guys.

    I am trying to simulate a mouse click on a button called "Working Time". I wrote the following applescript, but it is not working properly. I am getting the following error.

    Syntax Error

    Expected end of line, etc. but found identifier.

    Any ideas what is wrong? Is it my applescript or the javascript itself that is the problem?

    Code:
    tell application "Safari"
    	activate
    	do JavaScript "this.Response.Redirect("WebForm1.aspx?__EVENTTARGE T=Working Time")"
    end tell
     
  2. macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #2
    You have to escape the quotes in the script part.

    That just means put a \ before the " inside the do JavaScript command like this:

    Code:
    tell application "Safari"
    	activate
    	do JavaScript "this.Response.Redirect(\"WebForm1.aspx?__EVENTTARGE T=Working Time\")"
    end tell
     

Share This Page