tilt-shift photography of HTML codes

QR Coder for Mobile Devices

Being a mobile app developer, I have to keep few devices around me all day for debugging and testing my apps. Nowadays, all smartphones come with Bluetooth, WiFi and now NFC technologies, but they all fail to talk to each other for even simple text data exchange.

I find myself in situations where I need to quickly get piece of text from one device to another. It could be a link, some text copied from browser, or SMS message I received on one device, and need to get on other device without messing around with apps or wires.

QRCoder-demo

Yesterday this idea came to my mind when I was reading a lengthy article on my HTC Titan and received system notification that I need to recharge or else phone will power off. I wanted to quickly open the same article on my Nokia E7 which I was also carrying with me.

As I described earlier, that we currently don’t have any standard way to get these devices talk to each other directly without going through the “cloud”, so I was stuck there.

I quickly jumped back to my seat, and started some experiments. After an hour I did my first test and and it was a success!

I wrote a tiny JavaScript which can be added into mobile browser’s favorites, and when you need to share current page’s link with another device, you can just go to that saved Favorite, which will execute my JavaScript, which will finally render a QR Code right on top of the page.

Now you just need to point your other smartphone or tablet camera to it with a QR Code reader app of course (built-in in WP and other OS’s), and voila! The link will now open up.

It works in PC browsers as well, so if you need to quickly open a link on your tablet or smartphone from PC, you can save this in bookmarks toolbar in IE/Chrome/FF/Safari, and click it to instantly make a QR code for current link.

I tested it on all major PC browsers, and on my Nokia E7 and HTC Titan. Works great! It should run on all mobile browsers which support editing of bookmark URL, so you can insert the code there.

BTW, I used old Google Charts APIs to make the QR codes.

And finally here’s the code which you can copy and save as favorite in your mobile browser.

javascript:(function(){function QRCoder(){var u=window,t=document,n=t.createElement("div"),r=t.createElement("img"),i;r.src="https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl="+window.location,n.id="QRCoder",n.style.padding="60px",n.style.border="1px solid #f00",n.style.textAlign="center",n.style.backgroundColor="#ccc",n.onclick=function(){t.body.removeChild(t.getElementById("QRCoder"))},i=t.createElement("div"),i.style.fontFamily="tahoma",i.innerHTML="tap to hide",n.appendChild(r),n.appendChild(i),n.style.zIndex=6999,n.style.position="fixed",n.style.top="10px",n.style.left=u.innerWidth/2-130+"px",t.body.appendChild(n)}QRCoder();})()

Remember, there are no line breaks in this code. It’s just one long line of JavaScript code :)

Step by step guide:

  • Select and copy the above JavaScript code. On PC, do triple-click on code to select all code
  • Open web browser on mobile or PC
  • Add / save this page as bookmark or favorite
  • Now select and edit the saved bookmark
  • In name field, type “! QRCoder”. The character in start makes sure the bookmark is always on top of the list in your bookmarks list. Easy to tap :)
  • In Location / Address field, just paste the JavaScript code you copied in first step.
  • Ok / Done to save. Now go to any website and from bookmarks / favorites, tap on “! QRCoder”

To quickly land on this page, scan this QR code from your smartphone or tablet:

qrcoder-chall3ng3r

Tested on following devices / OS:

  • PC / Mac / Linux – Check
  • iPhone, iPad – Check
  • Windows Phone 7.5 – Check
  • Symbian Anna / Belle – Check
  • Z10 / BB10 – Check
  • ToDo: Android

I know when this gets published, many non-techy users are going ask how to save this code in mobile browser as favorite. So, here’s a little video demonstration on a Windows Phone:


[YouTube link for mobile viewing]

Kindly ignore audio/video quality and any narration mistakes, this is my first ever video, done really quick :D

It’s a quick and dirty hack to solve a problem. You can also hack it further as per your liking.

I would love to hear any feedback or a tweet :)

// chall3ng3r //

32 Comments

  1. rodneyej says:

    This is cool! I wish it was a WP exclusive! That way O can brag about the functionality, oh well I will anyways. Thanks for the..app? What kind of utility is this called anyways?

  2. Thanks for your appreciation.

    Well, I’d call it a JavaScript Hack :)

    // chall3ng3r //

  3. […] [source] If you liked this post, please leave your comments below to share your experience. Have questions? like us on facebook or join us on twitter and raise your questions to be answerd quickly. Follow @techprolonged Tweet orison […]

  4. Sania says:

    Wow.. Brilliant work!!
    Unique idea as usual ;) Keep this up..

  5. Thanks Sania :)

    // chall3ng3r //

  6. Andrei says:

    Nice hack!
    I am curious, do you know how many characters are allowed to be pasted for the URL in the favorite?

  7. […] vollen Artikel findet ihr Hier Comments […]

  8. @Andrei, QR code can store up to 7089 characters. I guess you wanted to know how long URLs one can embed in a QR code.

    Well, 7089 characters are good enough for most links ;)

    // chall3ng3r //

  9. @Andrei, ahh… Now I get it what you asked. That depends on browser. Each browser have its own limit. I haven’t tested this yet, so not sure exactly.

    // chall3ng3r //

  10. […] because of drained battery. Below is a video demo :Installing the code on Mobile and PC :Visit this post of Faisal where you can find the Javascript CodeCopy The code and add it to your favorites.To create a new […]

  11. Haymo says:

    Simply beautiful. Great Work!

  12. KoreyTM says:

    I saw your work featured on wpcentral.com’s front page, and I have to say – This is awesome! Great work, Faisal!

  13. […] – Visitare la pagina dove troviamo il bookmarklet per generare il codice QR   […]

  14. This is very cool. I was using a web form before to get my Axure prototype links via QR code in my device.
    But this is even more convenient.
    Thanks!

  15. @Haymo, @KoreyTM, @Lennart,

    Thanks guys. Glad you liked it and its helping you in daily tasks.

    // chall3ng3r //

  16. HAYSTACK510 says:

    How do you do it on a pc. Video please

    1. @HAYSTACK510, on PC, just add same page you are visiting in bookmarks. Then righ-click the bookmark, select properties/edit. Now you can change the bookmark’s name, and paster the code in Location/Address field. Will post a screen cast for it as well.

      // chall3ng3r //

  17. jb says:

    Thanks for share it. I have tested in
    * WP7 Tango OK
    * PC Google Chrome OK
    * PC Firefox OK
    * PC Opera 11.62 OK
    * PC IE 9 Fail.

  18. Hi, it’s a nice tool. I noticed that it doesn’t work with links from the Guardian newspaper’s mobile site so I think I found a bug. Any idea why they get mangled? (URLs like http://m.guardian.co.uk/ms/p/gnm/op/spOrW6krfRE-CN7UW24NA7A/view.m?id=15&gid=business/2012/may/11/jp-morgan-trader-london-whale&cat=top-stories)

  19. @jb, thanks for your tests.

    @Patters, thanks for reporting. Yes it looks like the url is not getting correctly processed for QR Coder. I will try with url-encode and update it here if it fixes the issue.

    // chall3ng3r //

  20. […] Coder for Mobile Devices at F ·L ·A ·S ·H ·I ·S ·M http://chall3ng3r.com/?p=2951 "Flash is my bloody constant" ~ […]

  21. […] 1 Time in 1 Post I use this QR Code by Faisal Iqbal bookmarklet to copy the URL from a page to my device: […]

  22. Hiram Fernandez says:

    This does not works in Safari, any advice?

    1. @Hiram, maybe try Chrome or Firefox?

  23. anthony says:

    I get a broken link where the QR code should be. Any advice? I’m using firefox on a PC.

    1. Anthony, I think the JS code in Firefox bookmark might be not correctly set. Try copying the QRCoder JS code again and setting it as bookmark’s address/URL field.

      I also use Firefox as my primary browser and code is working good for me.

      Give it a try and let me know if you still can’t get it working.

      Best,

      // chall3ng3r //

      1. anthony says:

        I tried again and I’m still getting the little square to pop up, but the actual QR code image is broken. Here’s a link to what it looks like:
        https://plus.google.com/photos/117932504663135231639/albums/6011773349356671713?authkey=CJD43OS9qMqOGg

        I did what I did before, which was go to your code example, click the “copy” icon, create a bookmark, edit the bookmark, paste the code into the address bar/url field, then go to a site and select it.
        Here’s what my bookmarks area looks like: https://picasaweb.google.com/117932504663135231639/May102014?authuser=0&feat=directlink

        I’m using Firefox 29.0.1 on a Win7 machine (AMD A6, 6GB ram, 1TB hd)

        1. Hi, let me do some tests on it.

          Can you also tell me if you get this on every website or is it on some specific website?

          // chall3ng3r //

  24. Linda Chadwick-Wirth says:

    I’m having the same problem that Anthony reported above. I just get an image holder pop up rather than a QR code. I’ve tried both Chrome and Firefox, using a Macbook. Did you find out what might be going on?
    This is SO cool I’m hoping you found a fix!
    Thanks,
    Linda

    1. I will post an update with different QR api provider than current Google engine. Check back this post soon.

      // chall3ng3r //

  25. […] is an update to my original QR Coder browser bookmark script. It’s been a while, and the Google Chart APIs I was using for this stopped working few days […]

Leave a Reply

Your email address will not be published. Required fields are marked *