在我的index.php頁面上,我使用jquery load()來加載div「bodycontent」中的其他頁面。這工作正常和丹迪。我禁用常規鏈接,並且必須使href成爲頁面名稱,而不使用php,並在load()發生時標記php。我在div中加載的一個頁面我的對話框在鏈接上彈出。加載()和getscript()並不總是工作
當您最初訪問該頁面時,此工作正常,但如果您通過單擊頁面上的「產品」或任何其他鏈接轉向,然後返回「主頁」並單擊鏈接「閱讀更多」,對話框將不會再顯示。你必須刷新,然後它會工作,直到你再次點擊一個鏈接。此外,這在我的IE 9,ver9.0.8中正常工作,但在工作中較老的IE(如8),並且至少有一個其他人在對話框中顯示不出來。在我的工作中也有IE9,儘管我刪除了臨時互聯網文件等,但這隻會無效。在我的電腦上,它可以正常使用全新的firefox,chrome和IE下載,所以我也想知道我的方法是否向後兼容並且跨瀏覽器,如果不是,我可以做到這一點。我也使用獲取腳本在一個函數與負載拉jQuery的,jQuery的UI和我的JavaScript文件的對話框。
我也看過像ajaxcomplete這樣的東西,但作爲我最初的作品,我真的不知道該怎麼做。
My site main index page loading home.php initially (the news, ect)
dialog.js:
$(document).ready(function() {
$('#dialogbox').dialog({
autoOpen: false,
title: 'Loading title...',
modal: true,
width: 500,
height: 400
});
});
function readMore(id,title,cat,desc,post,auth) {
//alert(id +","+ title +","+ cat +","+ desc +","+ post +","+ auth);
var $dialog = $('#dialogbox').html('Category: '+ cat +'<br/>'+ desc +'<br/>---------------------------------<br/>Posted by: '+ auth +'<br/>' + post);
$dialog.dialog('open');
$dialog.dialog("option","title",title);
}
我怎麼拉的功能readMore:如此反覆
<?php
require('config/dbconfig.php');
$query = "SELECT * FROM news ORDER BY id DESC LIMIT 4";
if ($stmt = $mysqli->prepare($query)) {
/* execute statement */
$stmt->execute();
/* bind result variables */
$stmt->bind_result($idn, $titlen, $categoryn, $descn, $postdaten, $authorn);
/* fetch values */
while ($stmt->fetch()) {
//echo 'id: '. $id .' title: '. $title;
echo "<table border='0'>";
$shortDescLengthn = strlen($descn);
if ($shortDescLengthn > 106) {
$sDCutn = 106 - $shortDescLengthn;
$shortDescn = substr($descn, 0, $sDCutn);
} else {
$shortDescn = $descn;
}
echo "<h1>$titlen</h1>";
echo "<tr><td>$shortDescn...</td></tr>";
echo '<tr><td><a href="javascript:void(0);" onclick="'
. 'readMore(' . $idn . ',' . htmlspecialchars(json_encode($titlen)) . ','
. htmlspecialchars(json_encode($categoryn)) . ','
. htmlspecialchars(json_encode($descn)) . ',' . htmlspecialchars(json_encode($postdaten)) . ','
. htmlspecialchars(json_encode($authorn)) . ')">Read More</a></td></tr>';
echo "<tr><td>Written by: $authorn</td></tr>";
echo '<tr><td><img src="images/hardcore-games-newsbar-border.png" width="468px" /></td></tr>';
}
echo "</table><br />";
/* close statement */
$stmt->close();
}
/* close connection */
$mysqli->close();
?>
,基本上我需要看到爲什麼這個ISN點擊一個鏈接後,我的工作就沒有了,而且它怎麼會更加cr oss瀏覽器和向後瀏覽器兼容。
哪個對話框?如果你在內容中動態加載,你是否重新實例化對話框? – kinakuta 2012-08-01 03:10:02
Jquery對話框。它也發佈在上面的代碼條中以啓動。每次我調用load時,它都會使用get腳本,並且php中的鏈接調用對話框的js函數,這就是home.php中的所有鏈接,它通過索引頁上的load()來提取。 – Grant 2012-08-01 03:25:59
我不確定你的意思是通過重新實例化對話框,但如果它設置home.php加載到一個div和閱讀更多鏈接拉對話框,然後去頁面上的鏈接,並去回到home.php它完全一樣,從我所知道的。 – Grant 2012-08-01 05:00:14