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 8198859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:02:54+00:00 2026-06-07T06:02:54+00:00

I am trying to load youtube videos using JS function. The intention is to

  • 0

I am trying to load youtube videos using JS function. The intention is to have the user simply copy and paste the youtube video URL into an input field and then have my JS code takes care of the loading part. Unfortunately I am not sure why js code is not loading anyvideo? JS FIDDLE

JS:

<script>
       $(document).ready(function(){
        var last_cnad_text_1 = '';
        var options_cnad_text_1 = {
        embedMethod:'fill',
        maxWidth:320,
        maxHeight: 320
        };
        function loadVideo()
        {
        val = $('#cnad_text_1').val();
        if ( val != '' && val != last_cnad_text_1 )
        {
        last_cnad_text_1 = val;
        $("#embed_cnad_text_1").oembed(val,options_cnad_text_1);
        }
        }
        $(function(){
        $('#cnad_text_1').keydown(loadVideo());
        $('#cnad_text_1').click(loadVideo());
        $('#cnad_text_1').change(loadVideo());
        });
        });
​</script>

html:

<html>

<div class="col1">Insert a youtube video Link</div>
   <div class="col2">
   <input id="cnad_text_1" type="text" name="cnad[text_1]">
   <div id="embed_cnad_text_1">
   <iframe></iframe>
    </div>
</div>​

</html>
  • 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-07T06:02:55+00:00Added an answer on June 7, 2026 at 6:02 am

    $('#cnad_text_1').keydown(loadVideo()); is wrong. You are calling the function immediately instead of assigning it as a callback for the event. Remove the () and it should work:

    $('#cnad_text_1').keydown(loadVideo);
    $('#cnad_text_1').click(loadVideo);
    $('#cnad_text_1').change(loadVideo);
    

    Actually you can condense it even more:

    $('#cnad_text_1').on('keydown click change', loadVideo);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load a YouTube video on a flash MovieClip using url http://www.youtube.com/v/4nRNoXT_gUc
I've got a chromless YouTube player that I'm trying to load videos into, but
Hi all im trying to load youtube/Dailymotion video using the iframe method in my
I'm trying to determine what is the most efficient way to load videos into
I am trying to play a youtube video in a Video View. I have
I'm trying to load fragments of XHTML markup using jQuery's $.fn.load function, but it
I am trying to load a dynamic library using dlopen function. This library contains
I'm trying to get the following functionality: Embed a youtube video into a webpage
I was trying to develop an application where I would load a Youtube video,
Im trying to load an xml file using the jquery ajax function,it works fine

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.