Author Topic: Problem with opendetailwindow() and a solution  (Read 5310 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Problem with opendetailwindow() and a solution
« on: February 04, 2003, 02:33:50 AM »
From thumbnail_bit.html:
Code: [Select]
<!-- you wish detail page in a small javascript open window, use {thumbnail_openwindow} -->
The current implementation of this has a small problem.  If the user SHIFT-Clicks on the thumbnail in IE, they get an empty 'detailwindow' browser popup and a 2nd, fully chromed browser window with the actual details.html.  By that I mean they get a 2nd browser window with all the toolbars, address bar, etc.

To prevent this from happening and make it so either clicking or SHIFT-Clicking on the thumbnail both produce a single popup as intended a change must be made to both php and javascript code.  Fortunately it's not that much.

You must edit 4images/top.php and 4images/includes/functions.php.  Locate all places where you find this code fragment:
Code: [Select]
onclick=\"opendetailwindow()\" target=\"detailwindow\">
And replace it with this:
Code: [Select]
onclick=\"opendetailwindow(this.href);return false;\">

Now edit the header.html template.  Change this block of code:
Code: [Select]
 function opendetailwindow() {
    window.open('','detailwindow','toolbar=no,scrollbars=yes,resizable=no,width=680,height=480');
  }

To this:
Code: [Select]
function opendetailwindow(url) {
detailwindow=window.open(url,'detailwindow','toolbar=no,scrollbars=yes,resizable=no,width=680,height=480');
detailwindow.focus();
}


*** NOTE ***
This doesn't stop the user who uses CTRL-Click in Netscape Navigator or Mozilla from opening details.html in a new tab inside the current, chromed browser.  Therefore, if you want to discourage this you can edit header.html and locate:
Code: [Select]
<script language="javascript" type="text/javascript">
<!--
  function opendetailwindow() {
    window.open('','detailwindow','toolbar=no,scrollbars=yes,resizable=no,width=680,height=480');
  }


And insert the 2 lines as shown:
Code: [Select]
<script language="javascript" type="text/javascript">
<!--

if( location.href.indexOf("details.php") != -1 && window.name != "detailwindow" )
  location.href = "http://www.YourDomain.com";

  function opendetailwindow() {
    window.open('','detailwindow','toolbar=no,scrollbars=yes,resizable=no,width=680,height=480');
  }

where you replace http://www.YourDomain.com with the URL of your web site.  This will momentarily reveal the URL of the details page but the browser will be redirected before any content is rendered.