SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Jan 2009
    Posts
    389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

    Code:
    $('#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 ?

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Stick it in the query string:

    Code javascript:
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •