Search code examples
facebookfbmlfbjsuservoice

How do I get the UserVoice Feedback Tab to display on a Facebook app page using FBML?


I have a Facebook application that is using FBML and I want to include the UserVoice feedback tab widget on my app's pages. I copied and pasted the JavaScript into my FBML page, but when Facebook renders the page, that JavaScript is removed, so the tab doesn't show up.

Does anyone have experience with Facebook's modified version of JavaScript and getting the UserVoice tab to work on a FBML page?

Here's the JavaScript code:

<script>
<!--
  var uservoiceJsHost = ("https:" == document.location.protocol) ? "https://uservoice.com" : "http://cdn.uservoice.com";
  document.write(unescape("%3Cscript src='" + uservoiceJsHost + "/javascripts/widgets/tab.js' type='text/javascript'%3E%3C/script%3E"))
//-->
</script>
<script>
<!--
UserVoice.Tab.show({ 
  /* required */
  key: 'callme',
  host: 'callme.uservoice.com', 
  forum: '31286', 
  /* optional */
  alignment: 'left',
  background_color:'#f00', 
  text_color: 'white',
  hover_color: '#06C',
  lang: 'en'
})
//-->
</script>

Solution

  • Forget about JavaScript. Just include the following HTML:

    <style type="text/css">
    #uservoice-dialog
    {
        display: block;
        margin: -2em auto 0 auto;
        position: absolute;
        text-align: left;
        z-index: 100003;
    }
    #uservoice-overlay
    {
        background-color: #000;
        filter: alpha(opacity=70);
        height: 100%;
        left: 0;
        opacity: .7;
        position: absolute;
        top: 0;
        width: 100%;
        z-index: 100002;
    }
    #uservoice-dialog[id], #uservoice-overlay[id]
    {
        position: fixed;
    }
    #uservoice-overlay p
    {
        color: #ddd;
        font: bold 14px arial, sans-serif;
        letter-spacing: -1px;
        margin: 0;
        padding: 5px;
    }
    #uservoice-dialog #uservoice-dialog-close
    {
        background-color: transparent;
        background-position: 0 0;
        background-repeat: no-repeat;
        color: #06c;
        cursor: pointer;
        height: 48px;
        position: absolute;
        right: -12px;
        top: -11px;
        width: 48px;
    }
    * html.dialog-open body
    {
        height: 100%;
    }
    * html.dialog-open, * html.dialog-open body
    {
        overflow: hidden;
    }
    html.dialog-open object, html.dialog-open embed, * html.dialog-open select
    {
        visibility: hidden;
    }
    * html #uservoice-overlay
    {
        width: 110%;
    }
    * html #uservoice-dialog #uservoice-dialog-close
    {
        background: none;
        filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='https://uservoice.com/images/icons/close.png');
    }
    a#uservoice-dialog-close
    {
        background-image: url(http://cdn.uservoice.com/images/icons/close.png);
    }
    </style>
    <a href="YOUR_USERVOICE_PAGE_URL_HERE" id="uservoice-feedback-tab">Feedback</a>
    

    That should put a UserVoice tab up on your page. You can customize the CSS as much as you like.

    Note that this skips the UserVoice modal dialog (which wouldn't work very well on Facebook anyways) and takes users directly to your UserVoice homepage.