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.

4 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