开发者

jquery and passing global variables

I have the following:

window.linkFrom;

$(document).ready(function(){

    $("a.linker").click(function(event){

            window.linkFrom = $(this).closest("div").attr("id");

            alert(window.linkFrom); 

            });开发者_如何转开发

 });

and want to pass the var linkFrom to a different script on a second page:

window.linkFrom;

(document).ready(function(){    

            alert(window.linkFrom);

});

How do I make this work?

TIA.


The script environments of two different pages are entirely independent, so you cannot communicate over variables like this. Basically you have two choices:

  1. Use cookies.
  2. Modify the calls to the second page to add e.g. #linkFrom=asdf to the address and parse that in the js of the second page.

Clarifying edit: scripts -> script environments

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜