Posts Tagged iPhone

iPhone Scroll To bookmarklet

Do you also get tiered of flickering your finger to scroll up and down loooong web pages? I was, so I wrote this JavaScript bookmarklet to do it for me. It enables you to enter a %-value where to (vertically) scroll on the page.

How to use it:

Just add and save a bookmark on any page. Open it for edit. Name it “Scroll to …” (or what ever) and paiste the JavaScript code below into the URL field.

javascript:window.scroll(window.pageXOffset,(prompt(%22Scroll%20to%20...%20(0-100)%22)/100)*document.body.clientHeight);

To use it, just select the bookmark from the bookmarks menu, enter a value between 0-100 (where 0 is the page top and 100 is the page bottom) into the prompt and hit OK.

Happy scrolling!

, , ,

1 Comment

iPhone view source

For you who are a web developer and would like to be able to “view source” on a web page with your iPhone Safari.
Create a bookmark. Edit it and paise the code below in the location field. Then when you want to use it, just click the bookmark, and you’ll get the source. Super easy!!

javascript:var%20sourceWindow%20%3D%20window.open%28%27about%3Ablank%27%29%3B%20%0Avar%20newDoc%20%3D%20sourceWindow.document%3B%20%0AnewDoc.open%28%29%3B%20%0AnewDoc.write%28%27%3Chtml%3E%3Chead%3E%3Ctitle%3ESource%20of%20%27%20%2B%20document.location.href%20%2B%20%27%3C/title%3E%3C/head%3E%3Cbody%3E%3C/body%3E%3C/html%3E%27%29%3B%20%0AnewDoc.close%28%29%3B%20%0Avar%20pre%20%3D%20newDoc.body.appendChild%28newDoc.createElement%28%22pre%22%29%29%3B%20%0Apre.appendChild%28newDoc.createTextNode%28document.documentElement.innerHTML%29%29%3B

,

No Comments

On page search for Mobile Safari on the iPhone

My older brother Joel just got home from Italy – and with him he brought an new shiny iPhone 3GS for me! So why bother getting it all the way from Italy you may ask? First of all it’s not released yet in Sweden (or maybe that’s today actually). Secondly and more important, what makes Italy (and Belgium) different from other European countries is that you can buy iPhones without any carrier restriction. You can use any carrier you want!

Anyways. I’ve been using it for two days now and I LOVE IT! Everything I got annoyed with and irritated over using my HTC Touch Diamond is gone. I must say, Windows Mobile sucks! Compared to the iPhone’s OS, WM is nothing! It’s like they come from different planets.

There is one thing that has been bothering me though. You can’t search the text on a page with Mobile Safari. When you view large pages on a relatively small screen, it’s necessary to be able to search it. Luckily there is a solution to the problem. At The iPhone Blog Rene Ritchie describes how you can to it with a simple bookmark! It sounds a bit weird, but all you need to do is to create a bookmark and replace the bookmark URL with some JavaScript (see code below). Then whenever you need to search a page, just click on the bookmark, enter your search text into the JavaScript prompt and click OK. The script will then highlight all the matches on the page. Super neat!!

javascript:void%28s%3Dprompt%28%27Find%20text%3A%27%2C%27%27%29%29%3Bs%3D%27%28%27+s+%27%29%27%3Bx%3Dnew%20RegExp%28s%2C%27gi%27%29%3Brn%3DMath.floor%28Math.random%28%29*100%29%3Brid%3D%27z%27%20+%20rn%3Bb%20%3D%20document.body.innerHTML%3Bb%3Db.replace%28x%2C%27%3Cspan%20name%3D%27%20+%20rid%20+%20%27%20id%3D%27%20+%20rid%20+%20%27%20style%3D%5C%27color%3A%23000%3Bbackground-color%3Ayellow%3B%20font-weight%3Abold%3B%5C%27%3E%241%3C/span%3E%27%29%3Bvoid%28document.body.innerHTML%3Db%29%3Balert%28%27Found%20%27%20+%20document.getElementsByName%28rid%29.length%20+%20%27%20matches.%27%29%3Bwindow.scrollTo%280%2Cdocument.getElementsByName%28rid%29%5B0%5D.offsetTop%29%3B

, , ,

No Comments