Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    go to specified position in another page

    help,
    i want move to a pericular possition in another page,
    ex:if i click on xxxxx in one page , iwant to go exactly where apporiate content is present in another page.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Pass a parameter through Address bar
    Example:
    index is
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    <
    script language="JavaScript" type="text/JavaScript">
    function 
    goA(s){
    if(
    s.selectedIndex>0){
    var 
    a=s.options[s.selectedIndex].text;
    location.href='next.html'+'?'+a;
    }
    }
    </script>
    </head>
    <body>
    choose the desired anchor where to scroll next.html page<br>
    <select onchange="goA(this)">
    <option>--choose an anchor--</option>
      <option>one</option>
      <option>two</option>
      <option>three</option>
    </select>
    </body>
    </html> 
    next.html is
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    <
    script language="JavaScript" type="text/JavaScript">
    function 
    scrollA(){
    var 
    anc location.href.split('?')[location.href.split('?').length-1];
    var 
    loc location.href.split('?')[0];
    location.href=loc+'#'+anc
    }
    onload scrollA;
    </script>
    </head>
    <body>
    NEXT PAGE<br>
    <a name="one"></a>
    anchor one<br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <a name="two"></a>
    anchor two<br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <a name="three"></a>
    anchor three<br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    </body>
    </html> 
    You may do similar if you want to go to a specific position in pixels, using scrollTo() method. This case the parameter passed will be that position (take care that the parameter passed becomes a string, so it must be parsed afterwards)
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    he could also just write the # in your 1st peice of code instead of ? and then save the seond piece of code.

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    er ... named anchors, anyone?
    *keep it simple (TM)

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I thought what I suggested was named anchors if it ain't could u tell me what it a named anchor is?

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Garadon is absolutely right... I am used to pass the parameter with the "neutral" '?' most of the time, thus I didn't realize that in this perticula case it was enough to write directly the anchor name.

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    <
    html
    <
    head
    <
    title>Untitled Document</title
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
    <
    meta http-equiv="Content-Style-Type" content="text/css"
    <
    meta http-equiv="Content-Script-Type" content="text/javascript"
    <
    script language="JavaScript" type="text/JavaScript"
    function 
    goA(s){ 
    if(
    s.selectedIndex>0){ 
    var 
    a=s.options[s.selectedIndex].text
    location.href='next.html'+'#'+a


    </script> 
    </head> 
    <body> 
    choose the desired anchor where to scroll next.html page<br> 
    <select onchange="goA(this)"> 
    <option>--choose an anchor--</option> 
      <option>one</option> 
      <option>two</option> 
      <option>three</option> 
    </select> 
    </body> 
    </html> 
    And now any code in next.html is unecessary.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #7
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thank you

    thank you friends.but my problem is if i have some 10 lines of text (example) in first page i.e 10 different lines ,if i click on first line it should go to first para of another page ,if i click on 6th line it should goto 6th para of another page.
    once again thank you for your help.

  • #8
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    <a href="page1.htm#para1">Link to page 1 and paragraph 1</a>
    <a href="page2.htm#para6">Link to page 2 and paragraph 6</a>


    <a name="para1"></a> Placed at the beginning of paragraph 1 in page1
    Blah Blah Blah




    <a name="para6"></a>Placed at the beginning of paragraph 6 in page2
    Blah Blah Blah
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #9
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanks

    thank you very much , it is working. once again thak you.


  •  

    Posting Permissions

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