Page 1 of 2

[SOLVED] Opening a custom sized window ...

Posted: Wed Sep 15, 2004 3:55 pm
by Jonelle
I got this code to open a new window ....

Code: Select all

<?php
$_page_cont[0]['TMI_Chat'] = TopCodeMenuItem ( $f(_t("Quick Tour")), "tour\index.htm",$site[url],0,"target=_blank" );
?>
... however, I don't want it to open any size it wants, I would like to customize it to a specific size, with no scrollbars, buttons, etc. Can someone help?

Posted: Wed Sep 15, 2004 3:57 pm
by MarK (CZ)
Check out JavaScript's window.open() syntax. (Google)

This is more Client-side than "PHP - Code" ;)

Posted: Wed Sep 15, 2004 4:08 pm
by Jonelle
i tried using that ... but all the quotes caused too many syntax errors

Posted: Wed Sep 15, 2004 4:17 pm
by MarK (CZ)
So post the code which was not working (how does it look in HTML).

Here's an example how it should look like:

Code: Select all

window.open("http://forums.devnetwork.net/", "devWin", "width=800,height=600,location=yes,menubar=no");

Posted: Wed Sep 15, 2004 4:23 pm
by Jonelle
it the same as that pretty much ... i tried putting it where the 'tour/index.htm' sits in the line i first posted and it didn't work

Posted: Wed Sep 15, 2004 4:34 pm
by feyd
post the code you tried.

Posted: Wed Sep 15, 2004 5:11 pm
by Jonelle

Code: Select all

$_page_cont&#1111;0]&#1111;'TMI_Chat'] = TopCodeMenuItem ( $f(_t("Quick Tour")), "window.open("tour/index.htm", "Quick Tour", "width=600,height=450,location=yes,menubar=no")",$site&#1111;url] );
i tried that ... and that's what didn't work for me. i think i'm totally doing something wrong, but i have no idea what.

Posted: Wed Sep 15, 2004 5:47 pm
by feyd

Code: Select all

$_page_cont[0]['TMI_Chat'] = TopCodeMenuItem ( $f(_t("Quick Tour")), 'window.open("tour/index.htm", "Quick Tour", "width=600,height=450,location=yes,menubar=no")',$site[url] );

Posted: Wed Sep 15, 2004 6:03 pm
by Jonelle
feyd wrote:

Code: Select all

$_page_cont[0]['TMI_Chat'] = TopCodeMenuItem ( $f(_t("Quick Tour")), 'window.open("tour/index.htm", "Quick Tour", "width=600,height=450,location=yes,menubar=no")',$site[url] );
okay, no errors this time, but it says that it can't find the page and the address in the address bar shows 'http://..../window.open('

Posted: Wed Sep 15, 2004 6:15 pm
by feyd
your function isn't setting the html right.

Posted: Wed Sep 15, 2004 6:22 pm
by Jonelle
feyd wrote:your function isn't setting the html right.
well, the entire function looks like this (and i think it's set up to only open up pages with no javascript functions or whatever) ...

Code: Select all

<?php
function PageCode( )
{
	global $dir;
    global $site;
	global $_page;
	global $_page_comp;
	global $logged;
	global $_SLMOD;
	global $tmpl;
	global $logged;
	global $ADMIN;
	global $tmi_letters;

	global $content_w;

	global $bgcolor;

	global $_page_cont;
	
	global $en_up;

	$ni = $_page['name_index'];

	$no_cart = getParam("no_cart") == "on" ? 1 : 0;
	$membership_only = getParam("membership_only") == "on" ? 1 : 0;

	// reading templates

	$fn = "$dir[root]tmpl_${tmpl}_page_$ni.html";
	if ( !file_exists($fn) ) $fn = "$dir[root]tmpl_${tmpl}_page.html";
	
	$fs = filesize ( $fn );
	$f = fopen ( $fn, "r" );
	$templ = fread ( $f, $fs );
	fclose ( $f );

	
	// lang block

	if ( $_SLMOD )
	{
		ob_start();	
			lang_select_txt();		
		$_page_cont[0]['switch_lang_block'] = ob_get_contents();
		ob_end_clean();
	}
	else
	{
		$_page_cont[0]['switch_lang_block'] = "";
	}

	// top menu items
	{
		switch ($tmi_letters)
		{
			case "upper": $f = "strtoupper"; break;
			case "lower": $f = "strtolower"; break;
			default: $f = "sprintf"; 
		}

		$_page_cont[0]['TMI_Home'] = TopCodeMenuItem ( $f(_t("_Homepage")), "index.php", $site[url] );

        $_page_cont[0]['TMI_Search'] = TopCodeMenuItem ( $f(_t("_Search")), "search.php", $site[url] );

		if ( $logged['member'] )
	        $_page_cont[0]['TMI_Join'] = TopCodeMenuItem ( $f(_t("Control Panel")), "member.php", $site[url] );
		else
	        $_page_cont[0]['TMI_Join'] = TopCodeMenuItem ( $f(_t("Register")), "join_form.php", $site[url] );

		if ( $logged['member'] )
			$_page_cont[0]['TMI_Login'] = TopCodeMenuItem ( (_t("Search")), "search.php", $site[url] );
		else
	        $_page_cont[0]['TMI_Login'] = TopCodeMenuItem ( $f(_t("Log In")), "member.php", $site[url] );

		
		if ( $logged['member'] )
			$_page_cont[0]['TMI_Chat'] = TopCodeMenuItem ( (_t("Chat")), "chat.php", $site[url],0,"target=_blank" );
		else
	        $_page_cont[0]['TMI_Chat'] = TopCodeMenuItem ( $f(_t("Quick Tour")), "tour\index.htm",$site[url],0,"target=_blank" );

		
		if ( $logged['member'] )
			$_page_cont[0]['TMI_Search'] = TopCodeMenuItem ( (_t("Communicator")), "cc.php", $site[url] );
		else
	        $_page_cont[0]['TMI_Search'] = TopCodeMenuItem ( $f(_t("Search")), "search.php", $site[url] );

		
		if ( $logged['member'] )
			$_page_cont[0]['TMI_Contacts'] = TopCodeMenuItem ( (_t("Log Out")), "logout.php?action=member_logout", $site[url] );
		else
	        $_page_cont[0]['TMI_Contacts'] = TopCodeMenuItem ( $f(_t("Contact")), "contact.php", $site[url] );


        if ( !$no_cart && !$membership_only && $logged['member'] )
	        $_page_cont[0]['TMI_Cart'] = TopCodeMenuItem ( $f(_t("_Cart")), "cart.php?t=".time(), $site[url] );
        else
	        $_page_cont[0]['TMI_Cart'] = TopCodeMenuItem ( $f(_t("_Chat Now")), "chat.php",$site[url],0,"target=_blank" );
			
        $_page_cont[0]['TMI_Forum'] = TopCodeMenuItem ( $f(_t("_Forum")), "forum.php",$site[url],0,"target=_blank");
        $_page_cont[0]['TMI_About'] = TopCodeMenuItem ( $f(_t("_About Us")), "about_us.php", $site[url] );
	}
?>

Posted: Wed Sep 15, 2004 6:53 pm
by feyd
I was actually referring to TopCodeMenuItem .. but you could just adding 'javascript:' to the front of the javascript code if it's generating an actual link.. however, I have no idea what your TopCodeMenuItem function does...

Posted: Wed Sep 22, 2004 10:21 am
by Jonelle

Code: Select all

<?php
function TopCodeMenuItem( $text, $link, $path = "", $dir = 0, $ex = "" )
{
    global $menu_item_width_a;
    global $menu_item_width_i;
    global $menu_text_margin_top;
    global $menu_item_height;
    global $site;
}
?>
Here's the TopCodeMenuItem function ... now how would I put in the javascript function to open a custom sized window??

Posted: Wed Sep 22, 2004 10:33 am
by Joe
Well its fairly difficult to work out some of your function routines but I would think something along the lines of:

untested:

Code: Select all

<script>
function open()
&#123;
 window.open('file.php',null,'height=470,width=400,status=yes,toolbar=no,menubar=no,location=no')
&#125;
</script>

<?php
function TopCodeMenuItem( $text, $link, $path = "", $dir = 0, $ex = "" )
&#123;    
 global $menu_item_width_a;    
 global $menu_item_width_i;    
 global $menu_text_margin_top;    
 global $menu_item_height;    
 global $site;
 print("<script>open()</script>");
&#125;
?>
would work...

Posted: Wed Sep 22, 2004 10:45 am
by feyd
I just noticed something.. the original code, had an illegal name for the window. spaces are not allowed.