Hey folks,
I've noticed that Herrera's open in a new tab bookmarklet
(http://doctyper.com/archives/200707/fixing-a-small-iphone-annoyance/
)
doesn't work in Windows Safari.* More worryingly, the bookmarklet doesn't
work when sync'd to my iPhone.
I've been able to resolve the iPhone issue by URL encoding the bookmarklet.
So for example,
javascript:(function(){var a=document.getElementsByTagName('a');for(var
i=0,j=a.length;i<j;i++){a[i].setAttribute('target','_blank');var img=
document.createElement('img');img.setAttribute('class',
'new-window');img.setAttribute('src','data:image/gif;base64,'+'R0lGODlhEAAMALMLAL66tBISEjExMdTQyBoaGjs7OyUlJWZmZgAAAMzMzP///////wAAAAAAAAAAAAAA'+'ACH5BAEAAAsALAAAAAAQAAwAAAQ/cMlZqr2Tps13yVJBjOT4gYairqohCTDMsu4iHHgwr7UA/LqdopZS'+'DBBIpGG5lBQH0GgtU9xNJ9XZ1cnsNicRADs=');img.setAttribute('style','width:16px!important;height:12px!important;border:none!important;');a[i].appendChild(img);}})();
becomes,
javascript:(function()%7Bvar%20a%3Ddocument.getElementsByTagName('a')%3Bfor(var%20i%3D0%2Cj%3Da.length%3Bi%3Cj%3Bi%2B%2B)%7Ba%5Bi%5D.setAttribute('target'%2C'_blank')%3Bvar%20img%3Ddocument.createElement('img')%3Bimg.setAttribute('class'%2C'new-window')%3Bimg.setAttribute('src'%2C'data%3Aimage%2Fgif%3Bbase64%2C'%2B'R0lGODlhEAAMALMLAL66tBISEjExMdTQyBoaGjs7OyUlJWZmZgAAAMzMzP%2F%2F%2F%2F%2F%2F%2FwAAAAAAAAAAAAAA'%2B'ACH5BAEAAAsALAAAAAAQAAwAAAQ%2FcMlZqr2Tps13yVJBjOT4gYairqohCTDMsu4iHHgwr7UA%2FLqdopZS'%2B'DBBIpGG5lBQH0GgtU9xNJ9XZ1cnsNicRADs%3D')%3Bimg.setAttribute('style'%2C'width%3A16px!important%3Bheight%3A12px!important%3Bborder%3Anone!important%3B')%3Ba%5Bi%5D.appendChild(img)%3B%7D%7D)()%3B
Although this latter bookmarklet works on my iPhone, it still doesn't work
in Windows Safari. Ironically, one of the commentators on Herrera's site got
the bookmarklet to work by stripping out the encoded characters instead of
encoding it as I've done here. On the other hand, I've compared notes with a
friend on the Mac and the original bookmarklet works fine on both his Mac
and iPhone but the URL encoded one doesn't work on his iPhone.
I'd like some corroboration of these results so I know I'm not crazy. Can
someone with a PC, a Mac, and an iPhone try and duplicate this? Thanks.
Best,
Ishan
* = Actually it sort of works in Win Safari. If you run the bookmarklet as a
link embedded in a webpage then it works. If you run the bookmarklet from
the Safari bookmarks bar then it will not work (and you get errors in the
javascript console).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---