I am working on a page that contains a digital phone directory. The names and numbers are listed, but I would like for more details about the entry to display in a popup when the name is clicked. Unfortunately, I am having a problem with the Javascript. I am very new to this language, but I think that either the code within the function I declared is wrong, the syntax of the argument I am passing is incorrect, or I omitted an essential part of the code. Any assistance you can provide on this issue would be greatly appreciated.
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script>
Function DisplayContactDetail(contact, windowname) {
window.open(contact, windowname);
}
</script>
<title>Cigna Security & Reception Phone Directory</title>
</head>
<body>
<div class="centerelement">
<div id="indexpageheader">
CIGNA SECURITY & RECEPTION DIGITAL PHONE DIRECTORY
</div>
</div>
<table>
<th colspan=2 width="auto">
ALLIEDBARTON
</th>
<tr>
<td width="50%">
<a href="" onclick="DisplayContactDetail('cigna.com','ContactDetail')">
NEPA District Office
</a>
</td>
<td>(610) 954-8590</td>
</tr>
<tr>
<td width="50%">Post Watch</td>
<td>(800) 643-8714</td>
</tr>
</table>
Thanks in advance!
-
So, what's the problem? Nothing happens? Getting unexpected results? An error occurs?Teemu– Teemu2013年07月21日 17:06:54 +00:00Commented Jul 21, 2013 at 17:06
-
Nothing happens when I click on hyperlink.Matthew Croft– Matthew Croft2013年07月21日 17:07:53 +00:00Commented Jul 21, 2013 at 17:07
-
<html> <head> <link rel="stylesheet" type="text/css" href="style.css"> <script> Function DisplayContactDetail (contact,windowname) { window.open (contact,windowname); } </script> <title>Cigna Security & Reception Phone Directory</title> </head> <body> <div class="centerelement"><div id="indexpageheader">CIGNA SECURITY & RECEPTION DIGITAL PHONE DIRECTORY</div></div>Matthew Croft– Matthew Croft2013年07月21日 17:23:32 +00:00Commented Jul 21, 2013 at 17:23
-
<table> <th colspan=2 width="auto">ALLIEDBARTON</th> <tr> <td width="50%"><a href="" onclick="DisplayContactDetail('cigna.com','ContactDetail')">NEPA District Office</a></td><td>(610) 954-8590</td> </tr> <tr> <td width="50%">Post Watch</td><td>(800) 643-8714</td> </tr> </table>Matthew Croft– Matthew Croft2013年07月21日 17:24:15 +00:00Commented Jul 21, 2013 at 17:24
-
It still does not do anything when I click on the link. I have included the complete code from the page.Matthew Croft– Matthew Croft2013年07月21日 17:24:54 +00:00Commented Jul 21, 2013 at 17:24
1 Answer 1
You've a quoting error in the value of the onclick attribute:
<a href="" onclick="DisplayContactDetail("http://www.cigna.com")">
Should be for example:
<a href="" onclick="DisplayContactDetail('http://www.cigna.com')">
Also Function should be function, JS is case-sensitive.