Pass variable to jQuery function in another page?

Pass variable to jQuery function in another page ?

Hi all

I have what I think is a simple question but I can’t find an answer.

I have two html pages - one.html, two html.

http://www.ttmt.org.uk/forum/3_call/one.html

http://www.ttmt.org.uk/forum/3_call/two.html

one.html contains a jquery function that alerts the variable it is passed.


$('#mess').click(function(){
      doAlert('testing');
    })

    function doAlert(message){
      alert(message);
    }

The problem is I want to call and pass the variable from another html page - two.html

How can I call and pass a variable to the jQuery function in one.html from two.html ?

Stick it in the query string:

var foo = 'bar';
window.location = 'two.html?foo=' + foo;

Then in two.html you can access that variable on the server side (e.g. with PHP: $_GET[‘foo’]). Or with JS you can access it via window.location.search.