19271Views4Replies

Author Options:

How do I make a button open a document. [HTML CODE]? Answered

I'm a beginner in HTML coding. When I click a button it should open a page or document. How should I do it. Sorry for my English :-((

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
nickworks
nickworks

12 years ago

<script type="text/javascript">
//<!--
function goToURL(val){
location.href = val;
}
//-->
</script>

<BUTTON ONCLICK="javascript:goToURL('some/url/index.html')">Click Me</BUTTON>

0
vijaykanth.k95
vijaykanth.k95

Answer 6 years ago

nice thanks

it was very useful :)

0
gmxx
gmxx

12 years ago

even easier... and i'll explain the coding too.

<a href="URL TO WEBPAGE OR DOCUMENT HERE">CHANGE THIS TEXT TO CREAT A LINK TO THE URL BEFORE, OR USE OTHER HTML, WHICH WILL BECOME LINKED TO THE DOCUMENT</a>

e.g.
<a href="http://instructables.com">Go to instructables</a>

<a


href="http://instructables.com">

>
Go to instructables

</a>


If you replace the part that says go to instructables with html that produces something on the screen, like images or bold or italic text, that will become clickable.

0
gmxx
gmxx

Answer 12 years ago

ooops... stupid auto-format. the middle part (where the lines are should be this:

e.g.
<a href="http://instructables.com">Go to instructables</a>

<a
>>Opens an anchor tag
href="http://instructables.com">
>>tells the browser where the link should go, this will be the url to the document or website
Go to instructables
>>this part will be the stuff you click to go to the stuff in the href attribute
</a>
>> this closes the HTML anchor tag, and must be there, or anytime you click anywhere on the page it will move you to the new site.