View Full Version : Popup window script

07-28-2007, 03:42 PM

Dynamic Drive has a script: Auto-centering Popup window - by Eric King.

Nice script and I would like to use it on a forum. Thing is, I'm relatively new to PHP and while I can use this script with no problem on regular html, trying to implement it in the forum code is tricky for me. I tried a few times but always ended up wiith the dreaded ol' 'Template Parse Error' page.

DD gives the basic instructions of where to place the script in the head section and then how to modify the link itself. I tried both and when it went TPE I went back and reinstated the original link. But it was still TPE and only when I removed the script from the head section did everything go back to normal.

Anyway, here's a part of the the forum code. The first one shows where I placed the script right before the end of the head section (blue text). The second shows the link in body; I won't display the adjustments I made since none of them seemed to work, the one displayed here is the one that works with the site and which I'm trying to modify for the popup.

1. Head section

document.getElementById("upshrinkHeader").style.display = mode ? "none" : "";
document.getElementById("upshrinkHeader2").style.display = mode ? "none" : "";
current_header = mode;

// the routine for the info center upshrink
echo '
<script language="JavaScript" type="text/javascript">
var current_header_ic = ', empty($options['collapse_header_ic']) ? 'false' : 'true', ';
function shrinkHeaderIC(mode)

if ($context['user']['is_guest'])
echo '
document.cookie = "upshrinkIC=" + (mode ? 1 : 0);';
echo '
smf_setThemeOption("collapse_header_ic", mode ? 1 : 0, null, "', $context['session_id'], '");';

echo '
document.getElementById("upshrink_ic").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");

document.getElementById("upshrinkHeaderIC").style.display = mode ? "none" : "";

current_header_ic = mode;

<script language="javascript">

Auto center window script- Eric King (http://redrival.com/eak/index.shtml)
Permission granted to Dynamic Drive to feature script in archive
For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
win = window.open(mypage,myname,settings)



2. Link

// Show the [Dictionary] button.
echo ($current_action=='Dictionary' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'dictionary' ? 'current' : '' , '"><a href="http://website.com"', $scripturl, '?action=Dictionary">' , $txt['Dictionary'] , '</a></li>';

Perhaps up the road when I get more acquainted with PHP this will be a breeze but right now it's a little windy.