admin管理员组

文章数量:1302379

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','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!

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.','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!

Share edited Jul 21, 2013 at 17:38 Teemu 23.4k7 gold badges58 silver badges111 bronze badges asked Jul 21, 2013 at 17:03 Matthew CroftMatthew Croft 711 gold badge2 silver badges9 bronze badges 5
  • So, what's the problem? Nothing happens? Getting unexpected results? An error occurs? – Teemu Commented Jul 21, 2013 at 17:06
  • Nothing happens when I click on hyperlink. – Matthew Croft Commented 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 Commented Jul 21, 2013 at 17:23
  • <table> <th colspan=2 width="auto">ALLIEDBARTON</th> <tr> <td width="50%"><a href="" onclick="DisplayContactDetail('cigna.','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 Commented Jul 21, 2013 at 17:24
  • It still does not do anything when I click on the link. I have included the plete code from the page. – Matthew Croft Commented Jul 21, 2013 at 17:24
Add a ment  | 

1 Answer 1

Reset to default 4

You've a quoting error in the value of the onclick attribute:

<a href="" onclick="DisplayContactDetail("http://www.cigna.")">

Should be for example:

<a href="" onclick="DisplayContactDetail('http://www.cigna.')">

Also Function should be function, JS is case-sensitive.

本文标签: Calling Javascript Function from HyperlinkStack Overflow