click makes page scroll far right

Discussion in 'Javascript' started by anna, Apr 9, 2004.

  1. anna

    anna Guest

    Is it possible to have a javascript function which can scroll a page
    to the far right when a link is clicked? Any code examples available?

    TIA,
    Anna
    anna, Apr 9, 2004
    #1
    1. Advertising

  2. anna

    anna Guest

    I tried the examples and it works fine with input type=button but
    doesn't work with type=image.

    Any way to make it work? Using the image look less clunky.

    <input type="button" value=">>" onClick="alignRight();"> //this works

    <input type="image" src="/icons/redarrow.gif" onClick="alignRight();">
    //rather have this work
    anna, Apr 9, 2004
    #2
    1. Advertising

  3. anna

    anna Guest

    Re: [SOLUTION] click makes page scroll far right

    What I ended up doing and it works for browsers NN4, NN7, and IE6.

    <a href="javascript:window.scrollTo(1000,0)"><img
    src="/icons/redarrow.gif" border=0 alt="Scroll right"></a>
    anna, Apr 9, 2004
    #3
  4. anna

    anna Guest

    SOLUTION:


    What I ended up doing and it works for browsers NN4, NN7, and IE6.

    <a href="javascript:window.scrollTo(1000,0)"><img
    src="/icons/redarrow.gif" border=0 alt="Scroll right"></a>
    anna, Apr 14, 2004
    #4
  5. anna

    anna Guest

    FOLLOWUP


    if (navigator.appName.indexOf("Netscape") != -1 &&
    parseFloat(navigator.appVersion) < 5 ) {
    if (document.width > window.innerWidth) {
    document.write('<a
    href="javascript:window.scrollTo(1000,window.pageYOffset)"><img
    src="/icons/redarrow.gif" border=0 alt="Scroll right"><img
    src="/icons/redarrow.gif" border=0 alt="Scroll right"></a>');
    }
    } else {
    if (document.body.scrollWidth > document.body.clientWidth) {
    document.write('<a
    href="javascript:window.scrollTo(1000,document.body.scrollTop)"><img
    src="/icons/redarrow.gif" border=0 alt="Scroll right"><img
    src="/icons/redarrow.gif" border=0 alt="Scroll right"></a>');
    }
    }
    anna, Apr 27, 2004
    #5
  6. anna wrote:

    > FOLLOWUP


    Do you really know what a followup is and what medium you are using?

    <http://www.faqs.org/faqs/usenet/posting-rules/part1/>

    > if (navigator.appName.indexOf("Netscape") != -1 &&
    > parseFloat(navigator.appVersion) < 5 ) {


    Nonsense. <http://pointedears.de.vu/scripts/test/whatami>

    Better:

    if (typeof document.width != "undefined"
    && typeof document.innerWidth != "undefined")
    {

    > if (document.width > window.innerWidth) {
    > document.write('<a
    > href="javascript:window.scrollTo(1000,window.pageYOffset)"><img

    ^^^^^^^^^^^^
    Nonsense. <http://jibbering.com/faq/#FAQ4_24>

    Better:

    if (document.width > window.innerWidth) {
    document.write(
    '<a
    + ' href="javascript:void(window.scrollTo(1000,window.pageYOffset))"'
    + ' onclick="window.scrollTo(1000, window.pageYOffset); return false"'
    + '><img ...');

    > src="/icons/redarrow.gif" border=0 alt="Scroll right"><img
    > src="/icons/redarrow.gif" border=0 alt="Scroll right"></a>');


    This will not work as supposed if you provide only one link with two images.

    > }
    > } else {
    > if (document.body.scrollWidth > document.body.clientWidth) {


    Again you did not test for those host objects and their properties before
    accessing them. See above.

    > document.write('<a
    > href="javascript:window.scrollTo(1000,document.body.scrollTop)"><img


    See above.

    > src="/icons/redarrow.gif" border=0 alt="Scroll right"><img
    > src="/icons/redarrow.gif" border=0 alt="Scroll right"></a>');


    See above.

    > }
    > }



    PointedEars
    Thomas 'PointedEars' Lahn, Apr 27, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page