Opening a new window

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Opening a new window

Post 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>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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)">
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

This is actually a PHP question because I can't figure out where to put that in my code.

Can anyone help?
rev
Forum Commoner
Posts: 52
Joined: Wed Oct 02, 2002 3:58 pm
Location: Atlanta, GA

Re: Opening a new window

Post 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...
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

<body onLoad="window.resizeTo(580,420)">
On this, how can I remove the toolbars, status bars, etc?

Thanks.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

I see this has been moved.

So, anybody have an answer to my question?

Thanks.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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>
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Odd javascript habit

Post 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
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post 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.
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
Post Reply