Hi Fellow JScript experts,

I was wondering if anyone had any suggestions of the correct way to right the function in the head section and calling it in the body section for this problem from my classwork.

Within the head section of the cover.htm file insert an embedded script containing the showForm() function. The purpose of this is to display the contents of the form.htm file in the main browser window. The function should:

  1. Display the form.htm file in the browser window that ws used to open the cover.htm file. (Hint: Use the "opener" keyword to reference the main browser window and the location.href property to specify the document to be displayed in the window.

  2. Locate the linked text in the body of the document and change the value attribute so that it runs the showForm() function when clicked.

Here is the code I have so far:


<link href="cover.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
//This function displays a pop-up window
function showForm() {

<body >

<div id="main">
<p><a href="javascript:showform('cover.htm') "onclick="return(showForm('cover.htm'))">
<b>Order 12 issues <br />for: $9.95*</b>
<p><img src="cover.jpg" alt="The Civil War Journal" /><br />
*25% off the <br />newsstand price!</p>


This class I am doing is online so all the reference material I have does not give basic information, but more advanced. Any help would be appreciated.

1 answer


You could probably add a link with something like:

<a href="#" onclick="showForm()">Go to the Form!</a>

or with a button:

<button onclick="showForm()">Go to the Form!</button>

The key, in both examples id the onclick attribute which tells the browser to call the showForm() function when the user clicks the that element.

Answered over 8 years ago by Daniel Lanigan
  • A better way would be to bind the function to the click event on the anchor tag. That way it's unobtrusive and you can have an actual URL in the HREF part, in case they don't have JavaScript enabled. Nathan DeGruchy over 8 years ago