How do you resize the new window you're opening?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Beefhead
Forum Newbie
Posts: 5
Joined: Sun May 16, 2010 9:47 pm

How do you resize the new window you're opening?

Post by Beefhead »

Hey guys

I've been trying to figure out the php code- or javascript/html, to resize the browser window once they click on my banner- which is an LP.

I have an image on a page that when the visitor clicks on it and gets transferred to the new page- I want the browser window to resize.

Any thoughts..?

I still need to maintain the target passthrough which is part of my problem.. so I need to integrate

Code: Select all

<BODY>
<?php  $passthrough = $_GET['target_passthrough'];

?>
  <a href="http://track.com/tracking202/redirect/dl.php?t202id=#&$#*&t202kw=<? echo $passthrough; ?>"><IMG SRC="http://url.com/images/sugar.jpg" border=0></a>

with..

<script>
<!--
function wopen(url, name, w, h)
{
 var win = window.open(url,
  name);
 win.resizeTo(w, h);
 win.focus();
}
// -->
</script> 
Cheers!
Last edited by Benjamin on Mon May 17, 2010 2:54 am, edited 1 time in total.
Reason: Added [syntax=html] tags.
Beefhead
Forum Newbie
Posts: 5
Joined: Sun May 16, 2010 9:47 pm

Re: How do you resize the new window you're opening?

Post by Beefhead »

I tried running this code but it only makes a little button. I want the whole banner/image/lp to be clickable to a larger browser window when it transfers to next page.

Thanks
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How do you resize the new window you're opening?

Post by Benjamin »

:arrow: Moved to Javascript
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How do you resize the new window you're opening?

Post by pickle »

When you create a new window, you can assign it to a variable:

Code: Select all

var myWin = window.open('window opening parameters go here');
You can then call resize() on that `myWin` variable.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: How do you resize the new window you're opening?

Post by kaszu »

Code: Select all

var myWin = window.open(url, name, 'width=' + w + ',height=' + h);
Beefhead
Forum Newbie
Posts: 5
Joined: Sun May 16, 2010 9:47 pm

Re: How do you resize the new window you're opening?

Post by Beefhead »

Inside a javascript tag or php tag?

Apparently window resizing is DOM which is javascript not php. However myWin looks like PHP..
Beefhead
Forum Newbie
Posts: 5
Joined: Sun May 16, 2010 9:47 pm

Re: How do you resize the new window you're opening?

Post by Beefhead »

Looks right.. but not working lol :drunk:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
<?php  $passthrough = $_GET['target_passthrough'];

?>

<script language="JavaScript">

var myWin = window.open('http://track.com/tracking202/redirect/dl.php?t202id=7697&t202kw=', Sugar!, 'width=1200' +  w + ',height=1200' + h);

</script>

  <a href="http://track.com/tracking202/redirect/dl.php?t202id=7697&t202kw=<? echo $passthrough; ?>"><IMG SRC="http://url.com/images/sugar.jpg" border=0></a>


 </BODY>
</HTML>
Last edited by Benjamin on Mon May 17, 2010 6:43 pm, edited 1 time in total.
Reason: Added [syntax=html] tags.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How do you resize the new window you're opening?

Post by Benjamin »

When you post HTML in the forum, please highlight the code, click the PHP Code button, and then change

Code: Select all

 to [syntax=html].

Thank you.
Beefhead
Forum Newbie
Posts: 5
Joined: Sun May 16, 2010 9:47 pm

Re: How do you resize the new window you're opening?

Post by Beefhead »

Got it! Looks like this..

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
<?php  $passthrough = $_GET['target_passthrough'];

?>

<script language="JavaScript">

function resize()
{

self.resizeTo(width=1200, height=1200);
window.location.href = "http://track.com/tracking202/redirect/dl.php?t202id=7697&t202kw=<? echo $passthrough; ?>";

}

</script>

 <a href="javascript:resize();"http://track.com/tracking202/redirect/dl.php?t202id=7xb7&t202kw=<? echo $passthrough; ?>"><IMG SRC="http://sugar.com/images/sugar.jpg" border=0></a>


 </BODY>
</HTML>
Sure Ben didn't realize. Cheers
Post Reply