PDA

View Full Version : DHTML Window Script, Javascript Pass url back to opener problem.



EZboy
07-31-2006, 04:04 PM
Hi there, i am using a DHTML Window script to open an image map in there. The idea is: after user clicks on certain area on the image map, the appropriate page loads in the "parent" window.
Here is the code that goes inside the DHTML Window:


<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript">

function selectItem(url){
window.close();
window.opener.location.href = url;
}
</script>
</head>

<body>

<img src="images/headend_d.jpg" alt="room_d" border="0" usemap="#map" />
<map name="map" id="map">

<area shape="rect" coords="67,647,89,683"
// Here the problem starts!!!
// When i use onclick, the area on the map is not clickable!

onclick="javascript:selectItem('http://www.someadress.com/show.php?id=2');"
//Here i try it with the href, the area is clickable, but nothing happens

href="javascript:selectItem('http://www.someadress.com/show.php?id=2')"
/>
<area shape="rect" coords="91,648,113,682" href="http://www.someadress.com/show.php?id=3" />

</map>
</body>
</html>


Am i doing something wrong?:( Thanks guys!

Twey
07-31-2006, 04:20 PM
The DHTML Window isn't really a window. It's an <iframe> inside a <div>. This might work:
function selectItem(url){
parent.location.href = url;
}

EZboy
07-31-2006, 04:34 PM
Great it works, even i the iframe is closed by itself.....magic:) thanks