Javascript link

Run Javascript code from HTML link.

Link code:

<a href="javascript:void(0)" onclick="myfunc()">Run Script</a>

Javascript code:

<script>
   function myfunc() { alert('myfunc() run'); }
</script>

View:

Run Script

Javascript link

Link code:

<a href="javascript:void(0)" onclick="window.location.href='../html/html-link.htm'">Link to page</a>

Link view:

Link to page

 

Selection link code:

<form name="selform">
<p><select name="linksel" onchange="OnSelChange()">
    <option>-- select page --</option>
    <option>HTML link</option>
    <option>Link color</option> 
    <option>Image link</option>
</select></p>
</form>
<script>
    function OnSelChange()
    {
        i = document.selform.linksel.selectedIndex;
        url = ['../html/html-link.htm', '../html/link/html-link-color.htm',
               '../html/link/html-image-link.htm'];
        if( i>0 ) window.location.href = url[i-1];
    }
</script>

Selection view:

Javscript back link

Link code:

<a href="javascript:history.back()">Back</a>

Link view:

Back

 

 


See also

Write how to improve this page

JAVASCRIPT
RAPID TABLES