Results 1 to 3 of 3

Thread: Scroll down to ?word? [HTML/PHP]

  1. #1

    Thread Starter
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Resolved Scroll down to ?word? [HTML/PHP]

    Urh, HTML n00b here... ^^

    how can I manage to scroll down to a word using a link, I thought it was done like this... but it doesn't work much... :

    Code:
    <a href='http://zhardablhar.com/pageX.htm#WORD'>tst</a>
    but nop, help the n00b plz...

    and I've designed my website in php so if you got a php function or somethin' don't be shy and post me that function plz!

    Last edited by Ruku; Jun 29th, 2005 at 10:42 PM.

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

  2. #2
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: Scroll down to ?word? [HTML/PHP]

    try this:
    HTML Code:
    <html>
    
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 15</title>
    </head>
    
    <body>
    
    <a href="#test">test</a><br>
    <a href="#hello">hello</a><br>
    <a href="#goodbye">goodbye</a><br>
    <a href="#google">google</a><br>
    <a href="#yahoo">yahoo</a><br>
    <a href="#computer">computer</a><br>
    <a href="#people">people</a><br>
    <a href="#coke">coke</a><br>
    <a href="#smoke">smoke</a><br>
    <a href="#slap">slap</a><br>
    <a href="#crack">crack</a><br>
    <a href="#argh">argh</a><br>
    <a href="#sniff">sniff</a><br>
    <a href="#stuff">stuff</a><br>
    <a href="#ruff">ruff</a><br>
    <a href="#cup">cup</a><br>
    <a href="#duff">duff</a><br>
    <a href="#dup">dup</a><br>
    <a href="#dump">dump</a><br>
    <a href="#argh">argh</a><br>
    <p><a name="test" href="#test">test</a></p>
    <a name="hello"><p>hello</p></a>
    <a name="goodbye"><p>goodbye</p></a>
    <a name="google"><p>google</p></a>
    <a name="yahoo"><p>yahoo</p></a>
    <a name="computer"><p>computer</p></a>
    <a name="people"><p>people</p></a>
    <a name="coke"><p>coke</p></a>
    <a name="smoke"><p>smoke</p></a>
    <a name="slap"><p>slap</p></a>
    <a name="crack"><p>crack</p></a>
    <a name="argh"><p>argh</p></a>
    <a name="sniff"><p>sniff</p></a>
    <a name="stuff"><p>stuff</p></a>
    <a name="ruff"><p>ruff</p></a>
    <a name="cup"><p>cup</p></a>
    <a name="duff"><p>duff</p></a>
    <a name="dup"><p>dup</p></a>
    <a name="dump"><p>dump</p></a>
    <a name="argh"><p>argh</p></a>
    
    </body>
    
    </html>
    you could also use a simple javascript:
    HTML Code:
    <head>
    <script language="JavaScript"> 
    <!-- Original by [url]http://javascript.internet.com[/url] More javascripts [url]http://www.hypergurl.com[/url] --> 
    var NS4 = (document.layers); // Which browser?
    var IE4 = (document.all); 
    var win = window; // window to search. 
    var n = 0;
    function findInPage(str)
    {
      var txt, i, found; if (str == "") return false; // Find next occurance of the given string on the page, wrap around to the // start of the page if necessary. 
      if (NS4) // Look for match starting at the current point. If not found, rewind 
      {
        // back to the first match.
        if (!win.find(str)) while(win.find(str, false, true)) n++; else n++; // If not found in either direction, give message.
        if (n == 0) alert("Not found.");
    }
    if (IE4)
    {
      txt = win.document.body.createTextRange(); 
      // Find the nth match from the top of the page.
      for (i = 0; i <= n && (found = txt.findText(str)) != false; i++)
      {
        txt.moveStart("character", 1); txt.moveEnd("textedit"); } // If found, mark it and scroll it into view.
        if (found)
        {
          txt.moveStart("character", -1); txt.findText(str); 
          txt.select(); txt.scrollIntoView(); n++;// Otherwise, start over at the top of the page and find first match. 
        }else{ 
          if (n > 0)
          {
            n = 0; findInPage(str);// Not found anywhere, give message.
          }else{
            alert("Not found.");
          }
        } 
      return false;
      }
    }
    </script>
    </head>
    <body>
    <form name="search" onSubmit="return findInPage(this.string.value);">
    <div align="center"> <p><font size=3> <input name="string" type="text" size=15 onChange="n = 0;">
    </font>
    <input type="submit" value="Search Page">
    </p>
    </div> 
    </form>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    hello
    </body>
    Last edited by ALL; Jun 29th, 2005 at 08:58 PM.
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  3. #3

    Thread Starter
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Re: Scroll down to ?word? [HTML/PHP]

    thx!


    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

Posting Permissions

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



Click Here to Expand Forum to Full Width