廣告

2015年11月19日 星期四

[android] Use "meta-data" from AndroidManifest.xml

想說第三方的app key參數都放在<meta-data >裡
但如果value直過大時(46464646464123),
ex:
<meta-data
    android :name="API_KEY"
    android :value="46464646464123 " />
此時直接從程式裡引用此值會出錯.

解法:
<meta-data android:name="zoo" android:value="@string/kangaroo" />

benefits:

2015年10月24日 星期六

Open new tab without popup blocker after ajax call on user click | 用ajax開新tab時,避免瀏覽器會詢問是否可開

是這樣的,我網頁上有個按鈕,點擊時會去
用jquery的ajax http get 去跟後端取資料,
並且取得後會開啟一個新分頁.

此時有個現象,
當ajax http get裡面的參數"async"設為true,
開新分頁時,browser 會問你可不可以跳視窗.

當ajax http get裡面的參數"async"設為false,
開新分頁時,browser 就不會問,而是直接地就
開啟新分頁.

PS:開啟新分頁是用window.open(url, '_blank')

以下為網友"Kenqr"的回答:
非由使用者的操作直接引發的開新視窗 瀏覽器會詢問,
點按鈕後直接開新視窗會被視為是使用者的操作引發的,
但async true時會在另一個thread執行,就不會被當成是使用者的操作,
可以改成點擊後直接開新分頁,新分頁裡再用ajax讀資料,
或是先開新分頁,原分頁讀到資料後再傳給新分頁應該也行
==================================
ref:http://stackoverflow.com/questions/18885676/open-new-tab-without-popup-blocker-after-ajax-call-on-user-click






2015年10月23日 星期五

Change the URI (URL) for a remote Git repository | 修改git remote的網址

有兩個方法:
1. edit .git/config and change the URLs there.

2. git remote set-url origin git://new.url.here


================================
show current remote url
git config --get remote.origin.url

2015年10月15日 星期四

AdBlock plus hids elements with ids or class with the word “ad”

chrome如果有裝adBlock的話在,html中 class的命名盡量不要出現以下相關字眼. => *ad*,*banner* 來源(https://easylist-downloads.adblockplus.org/easylist.txt)

2015年9月14日 星期一

[js] use jquery simulate trigger click event


jQuery(document).ready(function(){
    jQuery('#foo').on('click', function(){
         jQuery('#bar').simulateClick('click');
    });
});

jQuery.fn.simulateClick = function() {
    return this.each(function() {
        if('createEvent' in document) {
            var doc = this.ownerDocument,
                evt = doc.createEvent('MouseEvents');
            evt.initMouseEvent('click', true, true, doc.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
            this.dispatchEvent(evt);
        } else {
            this.click(); // IE Boss!
        }
    });
}


Purpose:simulate click function,
i use for bind of dynamic load page.

[js] pass parameter between two web app


flow:web_A pass parameter to web_B

method: use http get
.in web_A 's js file
   
   var url = "url?"+window.abStoreUserToken+"="+data[0]['userToken'];
   window.location = url;  
    
.in web_B 's js file

   //handle url redirect
    var hashTagQuery = handleHashTagString(window.location.search);
   
   //get parameter from another web 
    if(hashTagQuery['abStoreUserToken']!=null){
         sessionStorage.setItem(window.abStoreUserToken, _toJSONString(hashTagQuery['abStoreUserToken']));
    }
  
   //change url without reload, and clear ori url from history
    window.history.replaceState("object or string", "Title", "url without parameter" );
    
    
  

ref:
http://www.myexception.cn/javascript/249482.html
http://stackoverflow.com/questions/1961069/getting-value-get-or-post-variable-using-javascript

2015年9月8日 星期二

jquery screen resize event


    $(window).on('resize', function() {
        var win = $(this); //this = window
        console.log(win.height());
        console.log(win.width());
    });

Purpose:Do things when screen be resized