以下代碼運行良好,並在屏幕上啓動了一個Facebook彈出窗口,但是此彈出窗口未居中。在屏幕中心啓動Facebook共享彈出菜單
<script type="text/javascript">
function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}
<a href="http://www.facebook.com/share.php?u=<full page url to share" onClick="return fbs_click()" target="_blank" title="Share This on Facebook"><img src="images/facebookimage.jpg" alt="facebook share"></a>
這裏是中心的彈出窗口中的腳本:
<script type="text/javascript">
function MyPopUpWin(url, width, height) {
var leftPosition, topPosition;
//Allow for borders.
leftPosition = (window.screen.width/2) - ((width/2) + 10);
//Allow for title and status bars.
topPosition = (window.screen.height/2) - ((height/2) + 50);
//Open the window.
window.open(url, "Window2",
"status=no,height=" + height + ",width=" + width + ",resizable=yes,left="
+ leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY="
+ topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
}
</script>
可有人請更新一號腳本,使其結合工作與第二腳本導致在彈出窗口中的屏幕中央啓動。 (因爲我的編碼經驗非常有限,我不知道該怎麼做。) 感謝堆。皮婭
這絕對完美!你是一位超級天才編碼員,超級酷酷的人。謝謝。 :) Pia @arturhoo – user1736794
很高興知道它適合你! – arturhoo
正是我在找的東西 - 非常感謝你! – Ingusmat