JavaScript Facebook app browser debugging [duplicate] facebook browser debugging

I'm developing website with a lot of HTML5 and CSS3 features. I'm also using iframe to embed several content on my website. It works fine if I open it using Chrome/Firefox/Safari mobile browser. However, if I share on facebook (post/page) and I opened it up with Facebook application with Facebook Internal Browser, my website is messed up.

Is there any tools or way to debug on Facebook Browser? Thanks.

Answer:1

This is how you can do the debugging yourself. It's painful, but the only way I've come across so far.

tl;dr Get the Facebook App loading a page on your local server so you can iterate quickly. Then print debug statements directly to the page until you figure out what is going on.

  1. Get a link to a page on your local server that you can access on your mobile device (test in mobile safari that it works). See this to find out your local IP address How do you access a website running on localhost from iPhone browser. It will look something like this http://192.xxx.1.127:3000/facebook-test

  2. Post that link on your Facebook page (you can make it private so your friends aren't all like WTF?)

  3. Click the posted link in the Facebook mobile App and it will open up in Facebook's mobile browser

  4. Since you don't have a console, you basically need to print debug statements directly to the page so it is visible. Put debug statements all over your code. If your problems are primarily related to CSS, then you can iteratively comment out stuff until you've found the issue(s) or print the relevant CSS attributes using JavaScript. Eg something like (using JQuery)

    function debug(str){$('body').append("<br>"+str);}

  5. Quite possibly the most painful part. The Facebook browser caches very aggressively. If you are making changes and nothing has happened, it's because the content is cached. You can sometimes resolve this by updating the URLs, eg /facebook-test-1, /facebook-test-2, or adding dummy parameters eg /facebook-test?dummy=1. But if the changes are in external css or js sheets it sometimes will still cache. To 100% clear the cache, delete the Facebook App from your mobile device and reinstall.

Answer:2

The internal browser the Facebook app uses is essentially a uiWebView. Paul Irish has made a simple iOS app that lets you load any URL into a uiWebView which you then can debug using Safari's Developer Tools.

https://github.com/paulirish/iOS-WebView-App

Answer:3

I found a way how to debug it easier. You will need to install the Ghostlab app (You have a 7-day free trial there, however it's totally worth paying for).

  1. In Ghostlab, add the website address (or a localhost address) you want to debug and start the session.
  2. Ghostlab will generate a link for access.
  3. Copy that link and post it on Facebook (as a private post)
  4. Open the link on mobile and that's it! Ghostlab will identify you once you open that link, and will allow you to debug the page.

For debugging, you will have all the same tools as in the Chrome devtools (how cool is that!). For example, you can tweak CSS and see the changes applied live.

Answer:4

If you want to debug a possible error, you can try to catch it and display it.

Put this at the very top of your code:

window.onerror = function (msg, url, lineNo, columnNo, error) {
    var string = msg.toLowerCase();
    var substring = "script error";
    if (string.indexOf(substring) > -1){
        alert('Script Error: See Browser Console for Detail');
    } else {
        var message = [
            'Message: ' + msg,
            'URL: ' + url,
            'Line: ' + lineNo,
            'Column: ' + columnNo,
            'Error object: ' + JSON.stringify(error)
        ].join(' - ');

        alert(message);
    }
}

(Source: MDN)

This will catch and alert your errors.

Share a link on Facebook (privately), or send yourself a message on Facebook Messenger (easier). To break the cache, create a new URL every time, e.g. by appending a random string to the URL.

Follow the link and see if you can find any errors.

Answer:5

I am learning function programming in JavaScript, currently I have the following code. I would like to combine this two functions in another function which alllow an user to pass a value in and ...

I am learning function programming in JavaScript, currently I have the following code. I would like to combine this two functions in another function which alllow an user to pass a value in and ...

I am attempting to do jasmine-node unit testing on my node.js project. I need to get an array of file paths and then pass that array to the unit test. However, since this is asynchronous, I have to ...

I am attempting to do jasmine-node unit testing on my node.js project. I need to get an array of file paths and then pass that array to the unit test. However, since this is asynchronous, I have to ...

  1. return value asynchronous method javascript
  2. return value asynchronous function
  3. return value asynchronous swift
  4. return asynchronous value
  5. return value from asynchronous function javascript
  6. javascript return value asynchronous
  7. return value from asynchronous java
  8. return value ajax asynchronous
  9. return value from asynchronous callback
  10. promise return value asynchronous
  11. asynchronous return value c#
  12. node return value from asynchronous function

I need to add multiple attribute to input type file but I don't know how to do it. Below My code: var input = document.createElement("input"); input.type = "file"; input.id = "files" + af; input....

I need to add multiple attribute to input type file but I don't know how to do it. Below My code: var input = document.createElement("input"); input.type = "file"; input.id = "files" + af; input....

After long time searching here around I can't find a solution to this problem, loading Datatables via Ajax GET is well documented but how can I use directly a JSON response after an Ajax POST? This ...

After long time searching here around I can't find a solution to this problem, loading Datatables via Ajax GET is well documented but how can I use directly a JSON response after an Ajax POST? This ...

  1. load datatables from json
  2. load datatables from ajax
  3. datatables load from csv
  4. datatables load from array
  5. datatables load from json string
  6. datatables load from json file
  7. datatables load from api
  8. datatables load from server
  9. datatables load from object
  10. datatables js onload
  11. datatables load from table
  12. load datatables with filter
  13. datatables load from json
  14. datatables load data from ajax
  15. datatables load data from json
  16. datatables load data from array
  17. datatables load data from object
  18. datatables load data from variable
  19. datatables load data from server
  20. datatables load data from json file