Kdrumz Kdrumz - 4 months ago 19
Javascript Question

Having trouble directing button to google

I am having trouble linking a button to a page using javascript and html. I first add a button to a new page, then call the function. The button displays how I want it to in the new, blank display I created, which won't be shown here. All I need to do is when I click on the button I created, direct open up google.

Here is my javascript code(which isn't working, just posting what I have):

function addGoogle() {
page += "<button>Google Search</button>";
<button onclick="window.location= 'http://www.google.com';"

Here is my html code just in case:

<td> Google</td>
<td> Google Search</td>
<td> <button onclick="addGoogle()">Lets Search</button> </td>



I'm not sure I fully understand what you're trying to do. Looks like you're trying to get one button click to add another button, and then clicking on that second button to go to Google. If that's the case, the function might need to be something like:

function addGoogle() {
            page += "<button onclick=\"window.location='http://www.google.com';\">Google Search</button>";