General discussion

Locked

How to link javascript?

By azdavid99 ·
I have a javascript that I want to have run when the link is clicked. How do I do it?
Example -> to cause a linked page to open at a certain size by using javascript.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

How to link javascript?

by johnvogel In reply to How to link javascript?

To run a javascript program, whenever someone click on a link, you would use the onClick="" function. The syntax is:
<a href="http://site.url.com" onClick="ThisFunction(paremeters)">

Here's some HTML that does what you are talking about above, opens a link in a new sized window. You can copy this and pase it in your HTML editor.

<!-- BEGIN HTML CODE -->

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Example</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
-->
</script>
</HEAD>


<BODY>
<a href="http://www.techrepublic.com/" onclick="NewWindow(this.href,'name','400','400','yes');return false;">
Click here to

Collapse -

How to link javascript?

by azdavid99 In reply to How to link javascript?

Poster rated this answer

Collapse -

How to link javascript?

by azdavid99 In reply to How to link javascript?

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums