parse query string in href function?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Inny
    New Member
    • Nov 2007
    • 77

    parse query string in href function?

    Im trying to rewrite a link with a href function. I need to parse a query string within it ('+tid')

    But all attempts Have falied. The current onclick/ link function

    Code:
    <a href="java script:who_posted();">Who Posted?</a>
    is attached to my forums 'replys' number colum in forum veiw' {i have no direct access}

    it appears in the staus bar on hover as

    Code:
    <a href="java script:who_posted(428);">Who Posted?</a>
    where '428 is the tid (topic id).

    I want to write a href link to do this (elsewhere in html) and add the tid of whatever topic
    the page is currently on.

    see site for clarification (click the 'replies' number next to a title)

    http://inny.ipbfree.co m/index.php?showf orum=1

    click on any topic, and see a mail href link above. I want to add the who_posted function href there, so that whatever topic your on, the who posted box will work.

    code is {no direct access}
    Code:
    <script language='javascript' type="text/javascript">
    <!--
        function who_posted(tid)
        {
            window.open("http://inny.ipbfree.com/index.php?s=&act=Stats&CODE=who&t="+tid, "WhoPosted", "toolbar=no,scrollbars=yes,resizable=yes,width=230,height=300");
        }
    //-->
    </script>
    Im not sure to write the new link to include the extra function of adding the topic id (tid)

    i tried a few variations on
    Code:
    <a href="java script:window.open("http://inny.ipbfree.com/index.php?s=&act=Stats&CODE=who&t="+tid, "WhoPosted", "toolbar=no,scrollbars=yes,resizable=yes,width=230,height=300");>Who Posted?</a>
    and i thought it might be the quotes, i tried

    Code:
    <a href="java script:window.open('http://inny.ipbfree.com/index.php?s=&act=Stats&CODE=who&t='+tid, 'WhoPosted', 'toolbar=no,scrollbars=yes,resizable=yes,width=230,height=300')";>Who Posted?</a>

    No joy

    then i tried 2 functions

    Code:
    <a href="java script:who_posted(tid);window.open('http://inny.ipbfree.com/index.php?s=&act=Stats&CODE=who&t='+tid, 'WhoPosted', 'toolbar=no,scrollbars=yes,resizable=yes,width=230,height=300')";>Who Posted?</a>
    What am I doing wrong?
    please assist?
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Try this:
    ... &t='+tid+', ...

    Comment

    • Inny
      New Member
      • Nov 2007
      • 77

      #3
      Ok I tried this but I got page not found

      Code:
      <a href="java script:window.open("http://inny.ipbfree.com/index.php?s=&act=Stats&CODE=who&t='+tid+', "WhoPosted", "toolbar=no,scrollbars=yes,resizable=yes,width=230,  height=300");>Who Posted?</a>

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        [code=javascript]<a href="java script:window.o pen('http://inny.ipbfree.co m/index.php?s=&ac t=Stats&CODE=wh o&t='+tid+', WhoPosted', 'toolbar=no,scr ollbars=yes,res izable=yes,widt h=230, height=300');"> Who Posted?</a>[/code]
        Be careful while using quotes.

        Comment

        • Inny
          New Member
          • Nov 2007
          • 77

          #5
          It still gives 'page not found' I dont get it! :(

          Comment

          • Inny
            New Member
            • Nov 2007
            • 77

            #6
            There appears to be an extra function involved?

            Code:
            <script language='javascript'>
            <!--
             function bog_off()
             {
             	var tid = '1143';
             	var fid = '2';
             	
             	opener.location= 'http://inny.ipbfree.com/index.php?' + 'showtopic=' + tid;
             	self.close();
             }
             //-->
             </script>

            Comment

            • hsriat
              Recognized Expert Top Contributor
              • Jan 2008
              • 1653

              #7
              Try this...
              [code=javascript]<a href="javascrip t:window.open(' http://inny.ipbfree.co m/index.php?s=&ac t=Stats&CODE=wh o&t='+tid, 'WhoPosted', 'toolbar=no,scr ollbars=yes,res izable=yes,widt h=230, height=300');"> Who Posted?</a>[/code]

              I made a good mistake in the earlier one, although I was telling you to use quotes carefully.

              Harpreet

              Comment

              • Inny
                New Member
                • Nov 2007
                • 77

                #8
                Unfortunately This is not working either. I just dont understand it, Think it needs to add 'fid' (forum id) aswell, see extra function i found above.

                Comment

                • hsriat
                  Recognized Expert Top Contributor
                  • Jan 2008
                  • 1653

                  #9
                  Originally posted by Inny
                  Unfortunately This is not working either. I just dont understand it, Think it needs to add 'fid' (forum id) aswell, see extra function i found above.
                  I tried to do that on your website.
                  Altho I was scared from the snake out there, but what I suggested last time worked fine when I replaced tid with 1066. So I guess the value of tid is not being passed properly.
                  Type this in your address bar, press enter. It will work.
                  Code:
                  javascript:window.open("http://inny.ipbfree.com/index.php?s=&act=Stats&CODE=who&t=1066", "WhoPosted", "toolbar=no,scrollbars=yes,resizable=yes,width=230,  height=300");
                  Try to provide the tid to each link at server side by changing your PHP.

                  Comment

                  • Inny
                    New Member
                    • Nov 2007
                    • 77

                    #10
                    Thanks Mate, but I dont have access to the php.

                    Comment

                    • hsriat
                      Recognized Expert Top Contributor
                      • Jan 2008
                      • 1653

                      #11
                      Originally posted by Inny
                      Thanks Mate, but I dont have access to the php.
                      Then how to you get the value of tid?

                      Comment

                      • Inny
                        New Member
                        • Nov 2007
                        • 77

                        #12
                        Thats My Question Exactly, Its only apparent In the status bar When you mouseover the link.

                        Must be in the php.? When I use the Above in the browser address bar, the window pops up but the main page goes blank with [object] . Thats it.

                        Comment

                        • hsriat
                          Recognized Expert Top Contributor
                          • Jan 2008
                          • 1653

                          #13
                          Dude, you know its sometimes already difficult to interpret problems.
                          And since you have replied after weeks, it has become more difficult. I have forgotten what I was guiding you to do.

                          Post your full code, not snippets so that I can look into it and then tell you what's wrong.


                          Regards,
                          Harpreet

                          Comment

                          Working...