Results 1 to 3 of 3

Thread: DHTML Window Script, Javascript Pass url back to opener problem.

  1. #1
    Join Date
    Jul 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default DHTML Window Script, Javascript Pass url back to opener problem.

    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:
    Code:
    <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!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The DHTML Window isn't really a window. It's an <iframe> inside a <div>. This might work:
    Code:
    function selectItem(url){
    	   parent.location.href = url;
    }
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Great it works, even i the iframe is closed by itself.....magic thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •