JavaScript and client side scripting.
Moderator: General Moderators
evilmonkey
Forum Regular
Posts: 823 Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada
Post
by evilmonkey » Wed Oct 09, 2002 3:42 pm
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ї'id'];
$sql="SELECT id FROM userjokes WHERE validation='yes' ORDER BY id";
$res=mysql_query($sql, $db);
while ($row = mysql_fetch_object ($res))
{
print"<td><a href="archive2.php?id=$row->id">$row->id</a> ";
}
?>
</body>
</html>
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed Oct 09, 2002 3:52 pm
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 likeCode: Select all
<body onLoad="window.resizeTo(580,420)">
evilmonkey
Forum Regular
Posts: 823 Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada
Post
by evilmonkey » Wed Oct 09, 2002 4:29 pm
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
Post
by rev » Wed Oct 09, 2002 4:43 pm
Code: Select all
<?php
print "<td><a href="archive2.php?id=$row->id" target="new">" . $row->id . "</a>";
?>
target=? where ? is either a new window or you can reference a window name that is already open, etc...
evilmonkey
Forum Regular
Posts: 823 Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada
Post
by evilmonkey » Wed Oct 09, 2002 8:48 pm
<body onLoad="window.resizeTo(580,420)">
On this, how can I remove the toolbars, status bars, etc?
Thanks.
evilmonkey
Forum Regular
Posts: 823 Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada
Post
by evilmonkey » Thu Oct 10, 2002 12:03 pm
I see this has been moved.
So, anybody have an answer to my question?
Thanks.
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Thu Oct 10, 2002 1:18 pm
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)
{
window.open(sUrl,"myWindow","width=300,height=150,left=0,top=0,status=no,toolbar=no,menubar=no,location=no,scrollbars=no");
}
</script></head>
<body>
<button onClick="showDetails('someUrl.php')">open new window</button>
</body></html>
phpScott
DevNet Resident
Posts: 1206 Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.
Post
by phpScott » Thu Oct 10, 2002 3:04 pm
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
evilmonkey
Forum Regular
Posts: 823 Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada
Post
by evilmonkey » Thu Oct 10, 2002 5:02 pm
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 » Thu Oct 10, 2002 5:55 pm
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)
{
window.open(sUrl,"myWindow","width=300,height=150,left=0,top=0,status=no,toolbar=no,
menubar=no,location=no,scrollbars=no");
}
</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]