head

What is YouTube
trend what is youtube

How to add a YouTube search box to any website


First thing to do is -- just go to YouTube website and view the source of webpage and
search for <form, though it is clumsy and real tough to find the right code exactly needed for search. you can see the code similar to the one shown below.

<form id="search-form" action="/results" method="get" name="searchForm">
<input id="search-term" name="search_query" type="text" onkeyup="goog.i18n.bidi.setDirAttribute(event,this)" value="" maxlength="128" />
<select class="search-type" name="search_type">
<option value="">Videos</option>
<option value="search_users" >Channels</option>
</select>
<input id="search-button" type="submit" value="Search" />
</form>
Just by removing the unnecessary code that is not at all required to us we can simplify the above code to

<form action="/results" method="get">
<input name="search_query" type="text" maxlength="128" />
<select name="search_type">
<option value="">Videos</option>
<option value="search_users">Channels</option>
</select>
<input type="submit" value="Search" />
</form>


Now just replace form attribute action="/results" to action="http://www.youtube.com/results"


<form action="http://www.youtube.com/results" method="get">

To open the results in a new tab or window add attribute target="_blank"

<form action="http://www.youtube.com/results" method="get" target="_blank" >

Complete code:

<form action="http://www.youtube.com/results" method="get" target="_blank" >
<input name="search_query" type="text" maxlength="128" />
<select name="search_type">
<option value="">Videos</option>
<option value="search_users">Channels</option>
</select>
<input type="submit" value="Search" />
</form>


Output:



You can apply what ever styling you want and even make it more good looking(than youtube ;) )

Thank you.

13 comments:

  1. Iam not getting ads for my blog even my blog is more older than six months and i have enabled "show ads on my blog" But no ads at all why? please give a solution for this.

    ReplyDelete
  2. I think this is a really good article. You make this information interesting and engaging. You give readers a lot to think about and I appreciate that kind of writing.
    Search Button

    ReplyDelete
  3. Assign the correct category to your video also to make it easier for people to find. These are pretty important because it is the way YouTube uses to filter through the many videos that are held. There are millions there and categories will help to speed searches up.
    YouTube Abonnenten kaufen

    ReplyDelete
  4. Very good post. It's helpful.But I need YouTube search results on my blog.

    How can I do that job ?

    ReplyDelete
    Replies
    1. Did you ever figure this out? I'm trying to do the same thing

      Delete
  5. Ok http://islamm1.wapka.mobi

    ReplyDelete
  6. And what if I want to get the top 10 results in my own site..?

    ReplyDelete
  7. I know this is a super old post but I am trying to do something exactly like this, but instead of the target going to a separate page I need it to go to a div on my page. Is this possible?

    ReplyDelete