Page 1 of 1

Opening a new window

Posted: Wed Oct 09, 2002 3:42 pm
by evilmonkey
I have a code that shows an id. when that ID is cicked the rest of the fields load. Currently, it loads in the same window. I want it to load in a new window (pop-up) where I can specify the size (in pixels). How is this done?

Here's the code:

Code: Select all

<?php
$db = mysql_connect("localhost","","");
mysql_select_db("dbthawowi_2",$db);;
$callsign = $HTTP_POST_VARS&#1111;'id']; 
$sql="SELECT id FROM userjokes WHERE validation='yes' ORDER BY id";
$res=mysql_query($sql, $db);
while ($row = mysql_fetch_object ($res)) 
&#123; 
print"<td><a href="archive2.php?id=$row->id">$row->id</a> ";
&#125;
?>
</body>
</html>

Posted: Wed Oct 09, 2002 3:52 pm
by volka
definitely a client-side question

<a href="ulr" target="framename">...</a> will show the document in the frame/window framename.
How to specify the window-size in an <a> I don't know.
  • but you may do it with javascript
  • with winow.open

    Code: Select all

    oWin =window.open("file.html","myWindow","width=310,height=400,left=320,top=0");
  • or in the new document something like

    Code: Select all

    <body onLoad="window.resizeTo(580,420)">

Posted: Wed Oct 09, 2002 4:29 pm
by evilmonkey
This is actually a PHP question because I can't figure out where to put that in my code.

Can anyone help?

Re: Opening a new window

Posted: Wed Oct 09, 2002 4:43 pm
by rev

Code: Select all

&lt;?php
print "&lt;td&gt;&lt;a href="archive2.php?id=$row-&gt;id" target="new"&gt;" . $row-&gt;id . "&lt;/a&gt;";
?&gt;
target=? where ? is either a new window or you can reference a window name that is already open, etc...

Posted: Wed Oct 09, 2002 8:48 pm
by evilmonkey
<body onLoad="window.resizeTo(580,420)">
On this, how can I remove the toolbars, status bars, etc?

Thanks.

Posted: Thu Oct 10, 2002 12:03 pm
by evilmonkey
I see this has been moved.

So, anybody have an answer to my question?

Thanks.

Posted: Thu Oct 10, 2002 1:18 pm
by volka
I thought there were <meta>-tags that would do it at least for IE.
But I didn't find them :(

try this one

Code: Select all

<html><head><script langauge="JavaScript">
function showDetails(sUrl)
&#123;
	window.open(sUrl,"myWindow","width=300,height=150,left=0,top=0,status=no,toolbar=no,menubar=no,location=no,scrollbars=no");
&#125;
</script></head>
<body>
<button onClick="showDetails('someUrl.php')">open new window</button>
</body></html>

Odd javascript habit

Posted: Thu Oct 10, 2002 3:04 pm
by phpScott
Javascript has a odd habit when it comes to the the window.open() function.
All options are automatically set to on, 'yes or 1' however as soon as you declare one option 'scrollbars=yes' all the other options are turned off.
Weird I know but it offered me no end of grief until I figured that one out. And remeber that scrollbars is plural, singular doesn't work.

phpScott

Posted: Thu Oct 10, 2002 5:02 pm
by evilmonkey
The problem with javascript is that I can't pass $row on it (if you take a look at my code). I am wondering if this can be done in PHP or HTML.

Thanks.

Posted: Thu Oct 10, 2002 5:55 pm
by Coco
well i know sod all about javascript, but i would have assumed this would work:

Code: Select all

<html><head><script langauge="JavaScript"> 
function showDetails(sUrl) 
&#123; 
   window.open(sUrl,"myWindow","width=300,height=150,left=0,top=0,status=no,toolbar=no,
       menubar=no,location=no,scrollbars=no"); 
&#125; 
</script></head> 
<body> 
<button onClick="showDetails('archive2.php?id=<?= $row->id ?>')">open new window</button> 
</body></html>
cos i thought that $row was passed by html, not by php or java......

[edit=remove stupidity]

Posted: Thu Oct 10, 2002 7:58 pm
by volka
ah, didn't notice that

Code: Select all

$row = mysql_fetch_object ($res)
will assign an array to $row. Access it with

Code: Select all

$row&#1111;'id']
not $row->id --> http://www.php.net/manual/en/language.types.array.php