廣告

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)