跳到主要內容

fb share callback

<!DOCTYPE html>

<html>
<head>
  <meta charset="utf-8" />
  <title></title>
  <link href="https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css" rel="stylesheet">
  <style type="text/css">
    .share-button{font-family:FontAwesome;font-size:15px;color:#fff;background-color:#4267b2;border:1px solid #4267b2;border-radius:2px;padding:2px 5px 0 5px;cursor:pointer;}
  </style>
</head>
<body>
<div id="fb-root"></div>
<script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/zh_TW/sdk.js#xfbml=1&version=v2.8&appId=你的app id";
  fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));

  function share() {
    FB.ui({
      method: 'feed',
      name: '1拉1揪友趣/送1佰再抽1萬',
      link: 'https://www.1111.com.tw/17SP/join1and1/',
      picture: 'https://www.1111.com.tw/discuss/showimage.ashx?p=/zone/home2016_indexHeadBanner_2.png',
      description: '凡成功推薦1位朋友,加入1111會員,並完成雙認證(同一手機、E-mail僅能認證一次),即可獲得「 7-11 100元商品券 」'
    }, function (response) {
      if (response && response.post_id) {
        alert('謝謝你完成分享!');
      } else {
        alert('你取消了分享');
      }
    });
  }

</script>

  <input class="share-button" type="button" onclick="share();" value="&#xf082 分享" />
</body>
</html>

留言

這個網誌中的熱門文章

How to install iCloud on Windows Server

現象: iCloud 無法運行或發生錯誤 原因: 新版的 iCloud 只能在 Windows 7 或 8 運行 修改步驟: 1. 安裝  7-zip ,如果你還沒有安裝 2. 安裝 Orca , 這是 Microsoft 提供的 MSI 編輯器 3. 下載   iCloud control panel installer ,如果你還沒有下載 4. 用 7-zip 解壓縮  iCloudSetup.exe 5. 開啟 Orca,開啟 iCloud64.msi,假設你系統是64bit 6. 找到 LaunchCondition table 7. 將 LaunchCondition table 刪除 8. 存檔,關閉 Orca 9. iCloud64.msi 按右鍵,點安裝

jQuery: Radio Button, Checkbox and Selecter

Trigger the event: $("input[name='lom']").change(function(){ // Do something interesting here }); Radio Button: To get the selected value: var v=$('input[name=Sex]:checked').val(); if( typeof(v) == 'undefined'){ //there's no button selected } To select radio button from value: $("input[name=Sex][value='2']").attr('checked',true); To select radio button from index: $('input[name=Sex]')[1].checked = true; Checkbox: To see whether checkbox is checked: $('#chk').is(':checked'); To set checkbox: $("#chk1").attr("checked",''); $("#chk2").attr("checked",true); Selecter: To get the selected value: $('#selectList').val(); $('#selectList :selected').text(); To add a new option: $('#selectList').addOption(value,text);

Ajax pageview of Google Analytics

first, to be sure the google analytics api is new version, such as var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-xxxxxx-x']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); the way 1. use ajaxSetup for all calls to $.ajax. notice 1: ajaxSetup is better writeen within $( document ).ready() to be sure the google analytics api is loaded. notice 2: the opts.url is the ajax url you write, to record corect pageview, the best way is use fullpath, such as '/folder_name/filename.php' $(function () { $.ajaxSetup({ beforeSend: function (xhr, opts) { //avoid cache of the iOS6 Safa...