Jquery的ThickBox插件非常好用,可以顯示一張圖片、多張圖處、AJAX和IFrame等多種樣式的內(nèi)容到ThickBox,都要A click觸發(fā),而有的時(shí)候后臺程序根據(jù)不同權(quán)限顯示不同內(nèi)容,這時(shí)希望根據(jù)條件輸入框的值判斷是否顯示ThickBox的內(nèi)容,所需添加代碼如下:

<script type="text/javascript" src="<web.path:path/>/resources/js/jquery.js"></script>
<script type="text/javascript" src="<web.path:path/>/resources/js/thickbox.js"></script>
<link rel="stylesheet" href="<web.path:path/>/resources/css/thickbox.css" type="text/css" media="screen" />
<script type="text/javascript">
??? $(function(){
???????
??????? //init thickbox的默認(rèn)選擇器
?? ???? tb_init('a.thickbox, area.thickbox, input.thickbox');
?? ???? $("#thickButton").click(function(event){
?? ???? ???
?? ???? ??? event.preventDefault();
??????????? //如果name輸入框的值不為空, 則彈出thickBox對話框
?? ???? ??? if($("#name").val()!="") {
?? ???? ??? ??? tb_show("","url?height=300&width=400&inlineId=myOnPageContent",false);
?? ???? ??? }
?? ???? });
?? ?});
</script>

<input type="text" id="name"/>
<input title="ban another user" type="button" value="Show" id="thickButton"/>