Filed under: iPod Family, Internet, Internet Tools, iPhone
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!


![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 1)
Krioni said 6:09PM on 1-26-2008
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;}}
Reply
Kim Hill said 2:22PM on 12-07-2007
If your pasted text includes special characters (as in a URL), do you have to escape them to use this script?
Reply
punkassjim said 2:58PM on 12-07-2007
If 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.
Reply
jadam said 3:18PM on 12-07-2007
Thanks 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.
Reply
Phillip said 3:25PM on 12-07-2007
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...
Reply
Phillip said 3:27PM on 12-07-2007
And then I remember that the iPhone can't *select* text. Hmm.
webcrs said 10:36AM on 12-08-2007
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?
Reply
mobilemind said 3:12AM on 12-09-2007
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.
Reply