TUAW Responds: Reader Requests iPhone Javascript Pasting
TUAW reader jadam asks if someone would please code up a bookmarklet that allows you to paste into website fields. It's a bit of a hack but I've put together this bookmarklet that you can sync to your iPhone and paste a pre-defined phrase into Safari.
This version pastes the word TUAW but you can easily replace TUAW (defined by "replacetext") with any other phrase. The bookmarklet iterates through all the form fields on your page, allowing you to select where to paste. You're welcome, jadam!
Share
Source: http://pastebin.com/f68207d4b
Categories
TUAW reader jadam asks if someone would please code up a bookmarklet that allows you to paste into website fields. It's a bit of a hack...
Add a Comment
Phillip,
There is a "Personal Note..." bookmarklet that does what you mentioned. If you use that, and the variable name it uses is "iJ62mQcy" (see http://edmullen.net/Mozilla/bookmarklets.txt for more) then here is a version of iPastelet that will allow you to paste that text into form fields (after only typing it once):
javascript:var%20i,j,holdorig;var%20replacetext=iJ62mQcy;for%20(i=0;i%3Cdocument.forms.length;i++)for%20(j=0;j%3Cdocument.forms[i].elements.length;j++){if%20(document.forms[i].elements[j].type==%22text%22){holdorig=document.forms[i].elements[j].value;document.forms[i].elements[j].value=replacetext;var%20answer=confirm(%22Paste%20Here?%22);if%20(answer)%20break;%20else%20document.forms[i].elements[j].value=holdorig;}}
I thought this was pretty cool, so I hacked up a little web page with a form. Just enter the text you want the bookmarklet to paste and the name you want to give the bookmarklet. Very handy for making a little scrapbook of common web form text- email addresses, host and server names, etc. The form is at:
http://mobilemind.net/iphone/ipastelet.html
Thanks TUAW and thanks Erica.
I tried this out and it works just fine on safari on my pc, but when I sync it to my iPhone it doesn't do anything. I don't get any of the dialog boxes. I will disclaim that I am running safari on windows, not a mac. I have had a lot of problems with bookmarklets that are too large for safari on the pc, but they typically don't work on safari on the pc.
Any thoughts?
The iPhone uses cookies, doesn't it? If so, is it possible for a "copy" bookmarklet to store selected text to a "clipboard" cookie, and a "paste" bookmarklet to iterate through all the fields and paste from the clipboard cookie? Just a random thought which probably won't produce much fruit anyway...
December 07 2007 at 3:25 PM Report abuse Permalink rate up rate down ReplyAnd then I remember that the iPhone can't *select* text. Hmm.
December 07 2007 at 3:27 PM Report abuse Permalink rate up rate down ReplyThanks Erica! This will undoubtedly prove useful for pasting info like addresses, etc. into web forms. I'll be setting a few of these up for sure.
December 07 2007 at 3:18 PM Report abuse Permalink rate up rate down ReplyIf anyone has a good repository of bookmarklets for the iphone, please post up. I've found a ton I like, but in particular I'm looking for one that'll allow you to use a search engine that requires the POST method. All the usual ones, like dictionary.com and wikipedia, etc, all use the GET method (putting strings in the URL). I haven't found a single one that gets around the POST requirement.
December 07 2007 at 2:58 PM Report abuse Permalink rate up rate down ReplyIf your pasted text includes special characters (as in a URL), do you have to escape them to use this script?
December 07 2007 at 2:21 PM Report abuse Permalink rate up rate down ReplyHot Apps on TUAW
Deals of the Day
more deals- miFrame Picture Frame Dock for iPad for $64 + $8 s&h
- Refurb Apple iPod nano 8GB MP3 Player for $99 + free shipping, 16GB for $119
- Hannspree Apple-Shaped 28" 1080p LCD HDTV for $270 + free shipping
- Philips wOOx Alarm Clock Radio for Apple iPod / iPhone for $60 + free shipping
- iWatchz Elemetal Collection Bracelet for iPod nano for $75 + free shipping
- iFrogz Luxe Lean Hard Case for iPod touch for $10 + free shipping
Software Updates
more updates- EFI Firmware Update brings Lion Internet Recovery to 2010-model Macs
- OS X Lion 10.7.3 released with Safari 5.1.3, Wi-Fi bug fix
- Aperture updated to 3.2.2, addresses Photo Stream issue
- Apple updates Keynote to address Lion issues
- Google Search app gets new look on iPad
- Apple releases Apple TV Software Update 4.4.3



8 Comments