我有一個jQuery UI菜單,其中包含一個按鈕,一旦單擊該按鈕,就會打開一個ligthbox樣式的iframe。我想要按鈕單擊事件來抓取選定的菜單值並將其發送到在iframe中打開的頁面。我嘗試了一些不起作用的東西。下面的鏈接中的人設計了一個解決方案,使JavaScript會話變量沒有cookie,但我不能將一個變量傳遞給Session.setVar(字符串名稱,混合值),它總是返回false,這意味着沒有設置會話。它只有當我傳遞一個字符串作爲值時才起作用。 http://samuli.hakoniemi.net/javascript-session-variables-without-cookies/如何獲取從一個頁面到另一個頁面的JavaScript變量而無需獲取或發佈
mycode的:
<script>
$(function(){
$(".menu").menu({
var selection = ' ';
select: function (event, ui) {
$('.selected', this).removeClass('selected');
// selection is that variable I want to pass to the page that opens in the iframe:
selection = ui.item.addClass('selected').children('a').attr('name');
} // closes select function
}); // closes menu
$("button").click(function(){
//when the button is clicked the css lightbox effect happens and the div below opens an iframe containing the other page.
$("#light").css("display", "block");
$("#fade").css("display", "block");
}); //closes click()
}); // close function()
</script>
//iframe:
<div id="light" class="white_content"><iframe height= "400px" width ="450px" src="http://mydomain.com/invite_1.php"></iframe> </div>
<div>
<ul class="menu" id="menu">
<li><a href="#" name="academic_artStudies" id="academic_artStudies"><img src="" alt="" /><h2>Academic: Art Studies</h2></a></li>
<li><a href="#" name="academic_Literature"><img src="" alt="" /><h2>Academic: Literature</h2></a></li>
<li><a href="#" name="academic_socialSciences"><img src="" alt="" /><h2>Academic: Social Sciences</h2></a></li>
<li><a href="#" name="academic_physicalNaturalSci"><img src="" alt="" /><h2>Academic: Physical/Natural Sciences</h2></a></li>
</ul>
</div>
您需要cookies或本地存儲。 – adeneo 2013-04-07 19:25:36