SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2008
    Location
    Plymouth, United Kingdon
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery: getting the variable's value from a link

    Hi,
    Is it possible to get the values of variable from a link and then pass it into javascript?

    for instance from the link here,
    Code:
    <a href="incl_layouts/form_sign_up.php?w=500&h=100" class="load">Sign up</a>
    w=500 and h=100 are the values I want to pass into the function click() below,

    Code:
    $(".load").click(function(){
    	var path = $(this).attr("href");
    	var width = w;
    	var height = h;
    });
    Many thanks,
    Lau

  2. #2
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code JavaScript:
    $(".load").click(function(){
    	var path = $(this).attr("href");
    	var query= path.split('?');
        var dim= query[1].split('&');
        var w= dim[0].split('=')[1];
        var h= dim[1].split('=')[1];
    });

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2008
    Location
    Plymouth, United Kingdon
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by whisher View Post
    Code JavaScript:
    $(".load").click(function(){
    	var path = $(this).attr("href");
    	var query= path.split('?');
        var dim= query[1].split('&');
        var w= dim[0].split('=')[1];
        var h= dim[1].split('=')[1];
    });

    oh I see! thank you


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
  •