• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Open URL in Safari with Post params
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Open URL in Safari with Post params


  • Subject: Re: Open URL in Safari with Post params
  • From: Axel Luttgens <email@hidden>
  • Date: Sat, 12 Nov 2011 12:55:47 +0100

Le 11 nov. 2011 à 17:17, Simon Forster a écrit :

> [...]
>
> At the moment I've got to download the form in Safari, fill it in (programmatically) and then submit the form. This seems somewhat inelegant and a (small) waste of my time as I've got to wait for the page with the form in to be downloaded before I can fill it in. Far better to make the call directly to the CGI with the POST data from the off - except there doesn't seem to be a method to do this.
>
> In pseudo-code what I'm after is:
>
> tell application "Safari"
> 	activate
> 	tell window 1 to set current tab to make new tab
> 	set the URL of document 1 to "http://www.example.com/example.cgi"; using post data "name=Thomas"
> end tell

Hello Simon,

I now understand what you're trying to do and the constraints you're facing. :-)
The following should do the trick:

tell application "Safari"
	tell front window
		tell (make new tab)
			do JavaScript "
var F = document.createElement(\"form\");
F.setAttribute(\"method\", \"POST\");
F.setAttribute(\"action\", \"https://www.somwhere.net/login.cgi";);
var I = document.createElement(\"input\");
I.setAttribute(\"name\", \"identity\");
I.setAttribute(\"value\", \"fred\");
F.appendChild(I);
var I = document.createElement(\"input\");
I.setAttribute(\"name\", \"passwd\");
I.setAttribute(\"value\", \"bert\");
F.appendChild(I);
F.submit();
"
		end tell
	end tell
end tell

Of course, as in my previous post, the url and the needed fields are still hypothetical...

HTH,
Axel

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Open URL in Safari with Post params
      • From: Simon Forster <email@hidden>
References: 
 >Open URL in Safari with Post params (From: Simon Forster <email@hidden>)
 >Re: Open URL in Safari with Post params (From: Emmanuel LEVY <email@hidden>)
 >Re: Open URL in Safari with Post params (From: Simon Forster <email@hidden>)
 >Re: Open URL in Safari with Post params (From: Thomas Fischer <email@hidden>)
 >Re: Open URL in Safari with Post params (From: Simon Forster <email@hidden>)

  • Prev by Date: Re: Add metadata to an existing QuickTime Movie
  • Next by Date: Single application mode?
  • Previous by thread: Re: Open URL in Safari with Post params
  • Next by thread: Re: Open URL in Safari with Post params
  • Index(es):
    • Date
    • Thread