HTML Help
HTML Help Central . com

» Online Users: 78

0 members and 78 guests
No Members online
Most users ever online was 695, 02-16-2011 at 07:01 AM.

» Site Navigation

 > FAQ

» Domains For Sale

Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2013
    Posts
    2

    Jump to top of page

    Hi,

    I have a script that loads videos in a player on the top of page, that looks like this:

    <script type="text/javascript">
    function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
    window.onload = func;
    } else {
    window.onload = function() {
    if (oldonload) {
    oldonload();
    }
    func();
    }
    }
    }

    addLoadEvent(function() {
    return playVideo("video1","videoplayer");
    })


    Then the video is called via:

    <a HREF="#" onclick='return playVideo("video1","videoplayer")'>

    How would I ADD to this script so that the page went to the top each time a video loaded? I tried using anchor names, that didn't work. I was thinking something along the lines of:

    window.scrollTo(x-coord, y-coord);

    ; but where do I add that?

    Thanks!

  2. #2
    Join Date
    Sep 2007
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    369
    Hi there saintalphonzo,

    and a warm welcome to these forums.

    Can we have a link to the site in question or the full page code.

    This will enable us to assess the problem properly.

    Also note that this...
    Code:
    
    function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
    window.onload = func;
    } else {
    window.onload = function() {
    if (oldonload) {
    oldonload();
    }
    func();
    }
    }
    }
    ...is really old redundant code.

    Instead we now use...
    Code:
    
       window.addEventListener?
       window.addEventListener('load',init,false):
       window.attachEvent('onload',init);
    ..where init is the function name.

    Further reading:-

    Last edited by coothead; 12-04-2013 at 04:05 PM.
    http://www.htmlhelpcentral.com/messageboard/image.php?type=sigpic&userid=8698&dateline=1189772  724

  3. #3
    Join Date
    Dec 2013
    Posts
    2

    Jump to top

    Thanks coothead!

    The page in question is this one.

    If you click a link at the bottom of the page (or anywhere), I want the page to jump up so you don't have to scroll to get back to the video player.

    Thanks!

  4. #4
    Join Date
    Sep 2007
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    369
    Hi there saintalphonzo,

    scroll down the document to about line #239 and find this code..
    Code:
    
    <!-- Begin Title Bar -->
    <h1 class="channeltitle">Videos</h1>
    Then change it to...
    Code:
    
    <!-- Begin Title Bar -->
    <h1 class="channeltitle" id="gotovideo">Videos</h1>
    Now scroll down to about line #372 to the video links.
    Change the first one...
    Code:
    
    <a HREF="#" onclick='return playVideo("video1","videoplayer")'>
    ...to this...
    Code:
    
    <a HREF="#gotovideo" onclick='playVideo("video1","videoplayer")'>
    Notice the removal of "return" from the onclick event .

    Repeat this process for the rest of the video links.
    http://www.htmlhelpcentral.com/messageboard/image.php?type=sigpic&userid=8698&dateline=1189772  724

Similar Threads

  1. Image map - jump to section on same page?
    By JesterDev in forum HTML / XHTML / XML
    Replies: 2
    Last Post: 06-03-2006, 08:44 PM
  2. HELP: Page jump on load?
    By staticouture in forum HTML / XHTML / XML
    Replies: 1
    Last Post: 05-29-2006, 09:21 PM
  3. Tables with Page Jump
    By CariMae in forum HTML / XHTML / XML
    Replies: 3
    Last Post: 10-18-2005, 10:21 AM
  4. Page jump thingy!! HELP!!!!!!!!!!!!!!!!!
    By Roxxylp27 in forum HTML / XHTML / XML
    Replies: 1
    Last Post: 08-12-2004, 04:57 PM
  5. Jump to text in same page
    By Wulfdog in forum HTML / XHTML / XML
    Replies: 3
    Last Post: 12-12-2002, 12:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBadvanced CMPS v4.1.1