close

這是一個jquery的技術之一,其重點就是節省開啟瀏覽器+讀取網頁的速度

所以就等於在同個頁面內開啟另一個新的畫面,但是卻省到很多讀取時間,這也是現在網頁設計的趨勢

直接來說這樣子的功能要怎麼做

 

/*你可以用google或jquery的路徑*/
<link rel="stylesheet" href="http://static.jquery.com/ui/css/base2.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://jquery-ui.googlecode.com/svn/tags/latest/themes/base/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>

/*也可以下載放自己的主機裡*/
<link rel="stylesheet" href="css/base2.css" type="text/css" media="all" />
<link rel="stylesheet" href="css/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="css/ui.theme.css" type="text/css" media="all" />
<script src="_inc_sql/jquery.min.js" type="text/javascript"></script>
<script src="_inc_sql/jquery-ui.min.js" type="text/javascript"></script>

<script>


function opennews(k){      
    $(function() {
        $('#opennews'+k).dialog("destroy");
    
        $('#viewnews'+k).dialog({
            resizable: false,
            height:580,
            width:750,
            modal: true,
            buttons: {
                '關閉視窗': function() {
                    $(this).dialog('close');
                }
            }
        });
    });

}

</script>

 

這段程式是我自訂的函式,請各位要使用的朋友,自請定義。
註:以上這些段落皆放在</head>之前

再來 html、php 語法都放在<body></body>的中間

 

<ul><li><a id="opennews<?=$i;?>" style="cursor:pointer;" onclick="opennews(<?=$i;?>)"><?=$nrd['n_title'];?></a></li></ul>
<div id="viewnews<?=$i;?>" style="display:none;" title="<?=$nrd['n_title'];?>"><div align="right" style="font-size:.8em; color:#999;">update:<?=$nrd['n_date'];?></div><?=$nrd['n_content'];?></div>


<ul><li></li></ul>是項目清單
註:
不懂的人需先學會 html、css

以上有連接資料庫朋友,這樣的表現方式就可以執行成功,當然要換成你自己的變數跟連接資料庫

若你沒有連接資料庫,可以參考

http://jqueryui.com/demos/dialog/#modal-message

程式演示:http://www.fruitdays.com  最下面的最新消息就是這個效果

arrow
arrow
    全站熱搜

    六睏 發表在 痞客邦 留言(0) 人氣()