Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Hardware - Troubleshooting and Discussion > iPhone, iPad & iPod > "Paste" links in mobile Safari.

"Paste" links in mobile Safari.
Thread Tools
zro
Mac Elite
Join Date: Nov 2003
Location: The back of the room
Status: Offline
Reply With Quote
Feb 14, 2009, 04:12 AM
 
This is hacked out of the iPastelet JavaScript bookmark (bookmarklet) from http://mobilemind.net/___

But, I have no idea what using it will do to RAM usage or browser performance over time.

Code:
javascript:if(!top.name){top.name=location;alert(top.name+" - ready to paste!");}else{var i,j,oldtxt;var rtxt=top.name;for (i=0;i<document.forms.length;i++)for (j=0;j<document.forms[i].elements.length;j++){if (document.forms[i].elements[j].type=="textarea"){oldtxt=document.forms[i].elements[j].value;document.forms[i].elements[j].value=rtxt;var answer=confirm("Paste Here?");if (answer) break; else document.forms[i].elements[j].value=oldtxt;}}top.name="";}

What it does: When run takes the URL of the current window and saves it as a variable. Then when run again will look for "textarea" (unlike iPastelet's "text") form elements and ask in succession if you'd like to paste the info from the variable there and then clears it, readying it for another usage.

Why bother? Because sometimes I want to post a link here or elsewhere when using my iPhone but can't. Well, couldn't.

If any JavaScript experts want to chime in with any tips or warnings that would certainly be welcome. I'm honestly doubtful it's cleared out of RAM, but being nothing but fairly short strings shouldn't form a clot too soon.

Be aware that the "paste" function is actually setting the value of the form element. Which means anything typed into the text area before pasting will be replaced! So run this before typing.


Seems my link doesn't want to work, so you're going to have to create a new bookmark in Safari with this script as the URL and then sync to your phone (or touch).


Well it seems this only works if used in the same "window." In other words, when you find a page you'd like to post the url to, get to where you want to post it using the same window.
( Last edited by zro; Feb 25, 2009 at 03:45 AM. Reason: .... :|)
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 11:05 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,