0
我有一組鏈接,我打開fancybox並啓用箭頭,以便用戶可以單擊next和prev。每個鏈接都用iframe類和href ='/ editdata.aspx'進行裝飾。我將刪除箭頭並傳入當前索引,以便editdata.aspx保存按鈕可以說「保存並下一個」,直到它到達最後一個鏈接,然後它會說「保存並關閉」。如何將當前索引傳遞給fancybox iframe
從editdata.aspx我用
var numLinks = $(".link-items", parent.document.body).children("a.iframe").size();
這使我的鏈接總數。我只需要知道當前顯示給用戶的鏈接,以便我可以更新保存按鈕文本。
這裏是我的代碼在editdata.aspx樣本:
// change the save button to save and next if fancybox is loading multiple links
if (parent.$.fancybox) {
var links = $(".links", parent.document.body);
if (links && links.length > 0) {
var numlinks = $(links).children("a.popup").size();
var index = getParameterByName('index');
if (index == numlinks) {
// this element is the last item to display so change the "save and next" to "save and close"
$("#btnSave").val("Save & Close");
$("#btnSave").click(function() {
parent.$.fancybox.close();
});
}
else {
$("#btnSave").val("Save & Next");
$("#btnSave").click(function() {
parent.$.fancybox.next();
});
}
}
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
我怎樣才能做到這一點?易V2
這似乎並不爲我工作。 this.index的值始終是相同的數字。所有的href都有相同的索引值。 – Bob
我更新了我的問題,包括我在iframe頁面中使用的jquery。 – Bob
這絕對是爲我工作。順便說一句,你可以在iframe中獲得像 - parent。$。fancybox.current.index – Janis