#location

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FrEaKmAn
    New Member
    • Aug 2007
    • 46

    #location

    Hello,

    I don't know if this is possible, but I think that javascript could solve this. For example, can javascript locate or obtain, hm how to say...

    if we have link example.com/page#pagenumber

    so that javascript reads link and returns pagenumber?
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by FrEaKmAn
    Hello,

    I don't know if this is possible, but I think that javascript could solve this. For example, can javascript locate or obtain, hm how to say...

    if we have link example.com/page#pagenumber

    so that javascript reads link and returns pagenumber?
    [CODE=javascript]
    var anc = location.hash;
    //add this line if you have to remove #
    anc = anc.replace('#' , '');
    [/CODE]

    Comment

    • FrEaKmAn
      New Member
      • Aug 2007
      • 46

      #3
      Originally posted by hsriat
      [CODE=javascript]
      var anc = location.hash;
      //add this line if you have to remove #
      anc = anc.replace('#' , '');
      [/CODE]
      wow, thanks....

      we could also use direct replacement :P

      Code:
      var anc= location.hash.replace('#','');

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        Originally posted by FrEaKmAn
        wow, thanks....

        we could also use direct replacement :P

        Code:
        var anc= location.hash.replace('#','');

        :D

        ... I know...
        I thought may by you won't need to remove the #... thats why I wrote that comment.

        Comment

        • FrEaKmAn
          New Member
          • Aug 2007
          • 46

          #5
          Originally posted by hsriat
          :D

          ... I know...
          I thought may by you won't need to remove the #... thats why I wrote that comment.
          does anybody know if I can convert this variable into PHP variable??

          Comment

          • hsriat
            Recognized Expert Top Contributor
            • Jan 2008
            • 1653

            #6
            Originally posted by FrEaKmAn
            does anybody know if I can convert this variable into PHP variable??
            How do you want to send this variables to PHP?...

            If you are using AJAX then it can be sent as it is.
            If you have to send it after page submit, then assign this value to a hidden input inside the form.

            Comment

            Working...