How to make a search box search google with HTML? - html

Lately, I've been working on a page in html which is supposed to search Google. I have a search box and a button but I'm wondering what the most efficient way to get the results from Google and display them on my page. If anyone knows I'd be glad if they helped me out.
{EDIT}
This is just a little project I'm working on. To be more specific I'd like to make it where what is typed in the search box gets taken from www.google.com/search and then the results of the Google search are displayed below.

Answer & Demo
You can create a custom google search engine for your sites, follow the steps, then get the code and paste it in a div inside the body tag. Here is a JSFiddle with an example of this (site:stackoverflow.com).
You can then edit the way the engine looks in the look and feel tab in the edit search menu.
Hope this helps, good luck! :)

So you're saying you want an HTML page with a single input and a submit button.
When the user enters text into the input and then presses submit what would you like to happen?
I see two basic approaches.
Pass the search string as a parameter in the URL so the next page can be made aware of it using javascript. then use xmlhttprequest to grab the data from google and do a document.write to render the information to the user:
example
Insert a Div with some id in the page and then use the submit's onclick attribute to initiate an AJAX call that gets the data from google and then inserts it into the div's innerHTML without the need for multiple pages.
[UPDATE}
after looking into this it seems that XMLHttpRequest will not work with google and that the API is the way to go.
source

Related

VBA - How to select tab on webpage

I've seen a couple of questions similar to this but have had no success.
I am trying to write a piece of code after navigation to a secure webpage which will click on a tab and load this data (there is no URL behind the tab so cannot use that). I need to click on the sales tab which has the ID overview. Can someone please help me write a line of code which will find this object and click on it. HTML Code
Many thanks
fyi i tried stuff like
ie.document.getelementbyID("overview")(0).Click
You can select
ie.document.querySelector("div[id=overview]")
So if clickable try:
ie.document.querySelector("div[id=overview]").Click
Or simply
ie.document.querySelector("#overview").Click
That is assuming the element isn't inside a form/frame/iframe. Can't tell from the small HTML sample though.

How can I format an html page so that when a link is added to G , it looks nice?

Im building a new website, and I was testing the ability to add a "link" to google plus and have the article and it's content (summary) get pulled into google+.
When I do this today, all I see is an image - and no text. I'm sure that there is some formatting change I can make to the page to make the text come in... But I don't know what to do.
If there is a guide somewhere I would like to read it, but I cannot find one. Thanks for the help
An example page:
http://alexedison.com/index.php?indexNum=8
The easiest way is to create snippet data for your page. Google provides a tool for doing this as well as additional information at:
https://developers.google.com/+/web/snippet
You can validate the data on your page using the Google structured data testing tool:
https://www.google.com/webmasters/tools/richsnippets
There is no problem in your webpage.
Google Plus has change the look of each post.
now it shows only Image, Title along with given URL.
if you visit Google Plus , you can see posts without description meta information.

How to open an iframe from clicking an image

I'm wondering if anyone can help me. I'm hoping I can open an iFrame in the centre of my webpage from clicking a picture. So in effect the iframe would be hidden until the picture is clicked. I have a very small and simple upload form on another page that I would like to appear when the user needs to upload and click the picture. I've had a good look round on this site and google in general but not found what I'm looking for, or the basics weren't included because it's common knowledge for most people here. Would there also be a way of closing this when it's finished uploading too? The form currently diverts to the homepage when finished so It would be handy to have a close option as in the end (post successful upload) the iframe contents will be the same as the page it's displayed on.
The best/easiest I have come across has been on w3schools but I have read using html for iFrames is not widely accepted or it isn't the best option cross-browser.
I have been viewing and trying different code but without even the basic knowledge I can't get my head around it.
If anyone is able to help, please assume I'm 5 years old. I'm not daft but in terms of code I'm literally just starting.
Thanks in advance
You would need to add a javascript onclick function to your img tag which would open a new window upon a click. You would pass the window.open function the name of the html file you want to display. Something like this:
<img src="image.jpg" onclick="window.open('welcome.html')">

Jsoup - Trying to extract Comments number from web page

I'm trying to extract the overall comments number from a web page using Jsoup.
For example, here is a page (CNN): http://edition.cnn.com/2011/POLITICS/07/31/debt.talks/index.html?hpt=T1
I see that the class ID is cnn_strycmtsndff, but can't get to find the right command to extract it.
Can someone help?
Thanks
Unfortunately, I don't think Jsoup is going to cut it. If you use the Chrome developer tools you can clearly pick out the HTML used for presenting the "(##### Comments)" section, but if you just view the source, none of that information is there. It seems like they are using some Javascript to dynamically embed the information in the page.
This is what you see in "View Source":
<div id="disqus_thread"></div><script type="text/javascript" src="http://cnn.disqus.com/embed.js"></script>
So Jsoup will never be able to see the elements with the comment information.

Using an HTML select list as link list

I have seen some solutions on how to use a dropdown list in HTML as a combo link list with JS. Is there possibly a way to do it without JS directly with HTML?
Maybe sth with method="link"?
Without JS? Yes, do it server side (issuing an HTTP redirect in response to a form submission)
Directly with HTML? No.
It isn't a nice UI design though. Having links people can see without clicking, and can activate with a single click is much nicer.