14321Views4Replies

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 :-((

4 Replies

user
nickworks (author)2009-04-16

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

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

Select as Best AnswerUndo Best Answer

user
vijaykanth.k95 (author)nickworks2015-01-30

nice thanks

it was very useful :)

Select as Best AnswerUndo Best Answer

user
gmxx (author)2009-04-16

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.

Select as Best AnswerUndo Best Answer

user
gmxx (author)gmxx2009-04-16

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.

Select as Best AnswerUndo Best Answer