15096Views4Replies

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

Discussions

0
None
nickworks

9 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
None
gmxx

9 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
None
gmxxgmxx

Answer 9 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.