Pop-up new window (without nav tools - such as back but etc)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
billy_022
Forum Newbie
Posts: 6
Joined: Mon Nov 24, 2003 5:03 pm

Pop-up new window (without nav tools - such as back but etc)

Post by billy_022 »

How do you make a link start a new window which pops up - without the normal navigation tools which you find in a normal browser window.

I want the pop-up window to have a form in it, which enables the user to enter information, and then submit the form. The window should be set at a specific size (only small)

(this pop-up will take the role of a dialog box, which you might find in a windows application)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

this would be done in javascript, not PHP ;)
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Code: Select all

<script type="text/javascript">
window.open("page.php", "", "left=0, top=0, width=300, height=300, resizable=no, menubar=no, toolbar=no, location=no, status=no");
</script>
billy_022
Forum Newbie
Posts: 6
Joined: Mon Nov 24, 2003 5:03 pm

Post by billy_022 »

how do I execute that code from a php file?

So, I need to make that javascript the action of a button. So when the button is clicked, the action is that it calls that javascript..
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

its all html/javascript

i never really learnt much javascript, but from what i know, it'd be something like this:

Code: Select all

<html>
<head>
<script type="text/javascript"> 
function yourfunction() &#123;
window.open("page.php", "", "left=0, top=0, width=300, height=300, resizable=no, menubar=no, toolbar=no, location=no, status=no"); 
&#125;
</script> 
</head>
<body>
<a href="javascript:onclick(yourfunction)"><img src="button.gif"></a>
</body>
</html>
like that? (not sure..)
billy_022
Forum Newbie
Posts: 6
Joined: Mon Nov 24, 2003 5:03 pm

Post by billy_022 »

I could not get that to work, it just does nothing, and it says error on page down the button left corner
billy_022
Forum Newbie
Posts: 6
Joined: Mon Nov 24, 2003 5:03 pm

now - getting the original page to refresh

Post by billy_022 »

Hi, I got the above code working..

At the moment, I have a button in a.php, and upon clicking, it window.open() a new window(b.php), containing a form. The form posts variables back to a.php, however, the new window loads a.php, containing the new variables, but instead of this - I want the first window to load a.php. After this, I want to close the new window, which I can do easy by window.close();

So, how can I make the action of the form to load a .php file in a different window other than the current window?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

billy_022 wrote:So, how can I make the action of the form to load a .php file in a different window other than the current window?
To put it simply, you don't.

What you have to do is send the form (which is in the pop-up window) to another file in the pop-up file.

Now the trick is this. You need to get the PHP page that check the form to do one thing if the form is ok and another thing if it's not.
If the form is ok then you need to get the PHP page to write some javascript to the page. If the form is not ok then PHP will need to either display an error message or go back to the form.

The javascript would look something like this...

Code: Select all

<script type="text/javascript">
window.opener.location.href = "thePage.php";
window.close();
</script>
[/close]

The main window that launched the pop-up window will go to whatever page you change "thePage.php" to. And obviously the window.close() bit will close the pop-up window.
Post Reply