$(top.document).ready(function() {
$("*").click(processAction);
function processAction(e){
var clicked = e.target;
e.stopPropagation();
alert(clicked.tagName);
e.stopPropagation();
switch(clicked.tagName)
{
case "A":
newDialog("You've clicked on a link !", "Please Choose An Action <br> 1<br>3");
return false; // prevent the default action, e.g., following a link
break;
case "INPUT":
newDialog("You've clicked on a form !", "Please Choose An Action <br> 1<br>3");
return false;
break;
case "IMG":
newDialog("You've clicked on a picture !", "Please Choose An Action <br> 1<br>3");
return false;
break;
case "BUTTON":
newDialog("You've clicked on a button !", "Please Choose An Action <br> 1<br>3");
return false;
break;
default:
newDialog("You've clicked on a text !", "Please Choose An Action <br> 1<br>3");
return false;
}
};
function newDialog(mytitle, mycontent){
var $dialog = $('<div></div>')
.html(mycontent)
.dialog({
autoOpen: false,
open: function() {$("*").unbind('click', processAction);},
close: function() {$("*").bind('click', processAction);},
title: mytitle,
buttons: { "Cancel": function() { $(this).dialog("close"); }
}
});
$dialog.dialog('open');
}
我試着設置綁定和取消綁定點擊打開和關閉事件,在processAction()函數,但是,它似乎並沒有被工作按計劃進行。jQuery的:在用戶界面對話框禁用點擊功能