如何在没有get或post的情况下将javascript变量值从一个页面转换到另一个页面

时间:2013-04-07 19:25:03

标签: javascript session variables

我有一个带有按钮的jquery ui菜单,单击该按钮后会打开一个ligthbox样式的iframe。我希望按钮单击事件获取所选菜单值并将其发送到在iframe中打开的页面。我尝试了一些不起作用的东西。下面链接的人设计了一个解决方案,使javascript会话变量没有cookie,但我无法将变量传递给Session.setVar(字符串名称,混合值),它总是返回false意味着会话未设置。它只在我传递一个字符串作为值时才起作用。 http://samuli.hakoniemi.net/javascript-session-variables-without-cookies/

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>

1 个答案:

答案 0 :(得分:1)

如果方便的话,您可以使用网址参数。