jared kroh
jared kroh

Reputation: 51

Link from PHP page to open in a fixed size window

I am trying to create a link inside of a PHP search results page that allows the user to click "open" and have a 296 x 278 window come up where more information is displayed.

All of the PHP works correctly, i am just having trouble opening a link from the PHP page and having it open in a fixed sized window.

I have tried multiple different javascripts but i cannot seem to get it working correctly when trying to impliment it into my $output statement.

This is my current $output statement that i would like to open in the fixed sized window. It currently opens the page in a new tab.

$output .= "<tr><td>Drag & Drop:</b></td><td><a href='details/" . $row['idrop'] . "' target='_blank'>" . " Open " . "</a>";

Any help would be greatly appreciated. Thank you.

Upvotes: 0

Views: 2607

Answers (2)

user2249123
user2249123

Reputation:

Include this small javascript snippet in your code

<script language="javascript" type="text/javascript">

function popitup(url) {
    newwindow=window.open(url,'name','height=278,width=296');
    if (window.focus) {newwindow.focus()}
    return false;
}

</script>

And for your php $output variable

$output .= "<tr><td>Drag & Drop:</b></td><td><a href=""  onclick='return popitup(\"details/" . $row['idrop'] . "\")'>" . " Open " . "</a>";

Check the escape characters before executing this code.

Upvotes: 1

Raheel Hasan
Raheel Hasan

Reputation: 6023

try this:

$output .= "<tr><td>Drag & Drop:</b></td><td><a href='#_' target='_blank' onclick=\"open_me('details/{$row['idrop']}');\">Open</a>";

aand here is your JS function

<script>
function open_me(h_rf)
{
    window.open(h_rf,'_blank','width=296,height=278,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=0,left=0,top=0');

    return false;
}
</script>

read more about this function from here: http://www.w3schools.com/jsref/met_win_open.asp

Upvotes: 3

Related Questions