Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8202591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:14:23+00:00 2026-06-07T07:14:23+00:00

I have a number of links on my page that calls some jquery code

  • 0

I have a number of links on my page that calls some jquery code to open up a video. The list of links can get quite long on the page. When someone clicks on a link I want it to position you to the part of the page where the video opens (<div id="player">). I thought putting in <a href="#player"... would do the trick. What am I missing?

<div id="player"></div>
<a href="#player" onclick="DoNav('<?php echo $url; ?>');"> <?php echo $result_videos[$i]["camera_name"]; ?> </a>

<script type="text/javascript">
function DoNav(theUrl)
{
  // only add the player if it doesn't yet exist
  if($('#myfileplayer').length == 0) {
    var mydiv = $("#player");
    var myvideo = $("<video id='myfileplayer' src='"+ theUrl + "' width='320' height='240' controls></video>");
    mydiv.append(myvideo);
  } else {
    $('#myfileplayer').attr("src",theUrl); 
  }

} 
</script>

The code above kinda works for the first click of a video, although it positions you under the video player instead of on top. The second time I go down the list of links and click one, it doesn’t do anything at all.

I’ve also tried adding <a name="blah"></a> (that is so html4) above the div then change the href to: <a href="#blah".... That doesn’t work either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:14:24+00:00Added an answer on June 7, 2026 at 7:14 am

    If I understood correctly you want your window to be scrolled to the div#player top when a link is clicked?

    Then you could do this via jQuery when you open the video

    Something like this should do the trick:

    $("yourLinkSelector").live('click', function(evnt){
        evnt.preventDefault();
        $('html, body').animate({scrollTop:$("div#player").offset().top - 50}, "slow");
        //then your code to open the video
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a number of links which I would like to get some information
I have any number of anchor links on a page that need to execute
I have a number of outgoing links on my webpage that I want to
I have a fairly simple HTML page with a link on it that calls
I have an application that executes this piece of code (JQuery 1.4.2) in an
I have a page that calls about 32 stylesheets. On another page, it calls
I have developed a program that is counting the number of lines in a
I have 2 simple questions about python: 1.How to get number of lines of
I have JS : jQuery('.unblock').click(function(){ var num = jQuery('.page.active').text(); var ban_id = jQuery('.unblock').attr('id'); jQuery.post('http://127.0.0.1/auth_system_1/user_activity/delete_user_ban',
So I have an interesting issue. I have a page that allows users to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.