Hi
I’ve been reading the book “JavaScript the definitive guide” to learn more about JavaScript. In this book he gives an example function to create pop-ups. The example function is in the code posted below. This function is shown in the book without examples of how you evoke it. So I added a little more code to try it. When I evoke it was a onclick event to function works fine however when I evoke it with a mouseover event (see commented out code in posting) the firebug debugger generates this error “w has no properties [Break on this error] var d = w.document; // Get its Document object DynamicContent.ht… (line 13)”. So why does evoking this function was an onclick event work while evoking it with an onmouseover event fail?
Sincerely
Marc
[code]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head>
<title>JavaScript Window Open Example</title>
<link rel=”STYLESHEET” type=”text/css” href=”/style/jsc.css”>
<script language=”javascript” type=”text/javascript”>
<!–
// This function opens a pop-up window. Invoke it from an event handler
// or the pop up will probably be blocked.
function hello() {
var w = window.open(); // Create a new window with no content
var d = w.document; // Get its Document object
d.open(); // Start a new document (optional)
d.write(“<h1>Hello world!</h1>”); // Output document content
d.close(); // End the document
}
window.onload = function(){
document.getElementById(“helloID”).onclick=hello;
//document.getElementById(“helloID”).onmouseover=hello;
};
</script>
</head>
<body>
<a href=”#” id=”helloID”>Link to popup</a>
</body>
</html>