The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
popup window doesn't work??(Javascript and some PHP)
Discuss popup window doesn't work??(Javascript and some PHP) in the JavaScript Development forum on Dev Shed. popup window doesn't work??(Javascript and some PHP) JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

July 21st, 2001, 10:02 AM
|
|
Junior Member
|
|
Join Date: Jul 2001
Location: Netherlands
Posts: 8
Time spent in forums: 1 h 9 m 13 sec
Reputation Power: 0
|
|
popup window doesn't work??(Javascript and some PHP)
Hi, I just want to open a page in a popup window without all bars...
I'm using the script below....but it doensn't open a popup window....can somebody help me with this?
I'm totally no Javascript expert! 
So please use examples...
In this script I'm also using some php because there has to be some variables send with the link to the popup page. (sorry about my english, it's not my native language)
=================CODE===================
<html>
<head>
<script>
function popup_mailfriend()
{mailfriend = window.open('send_to_friend.php', 'width=500,height=500,toolbar=0,scrollbars=0,location=1,statusbar=1,menubar=0,resizable=1,titlebar=1 ')
mailfriend.focus();
}
</script>
</head>
<body>
<?
echo "<a href='", "send_to_friend.php?section=$section&topic=$topic&subtopic=$subtopic&subsubtopic=$subsubtopic";
echo "' onCLick='popup_mailfriend()'>Email this page to a friend</a>";
?>
</body>
</html>
===============END CODE================
Thanks in advance for your help.
- Boszy -
|

July 21st, 2001, 10:56 AM
|
|
Contributing User
|
|
Join Date: Jun 2001
Location: Toronto, Ontario, Canada
Posts: 631
Time spent in forums: 7 m 19 sec
Reputation Power: 12
|
|
I don't know PHP, but here's an example of how to open a window
Code:
<html>
<head>
<title>Untitled</title>
<script language="javascript">
function newWin() {
window.open('http:\\src','name','toolbars=0,....')
}
</script>
</head>
<body>
<a href="javascript:newWin()">Open the window</a><!--There should be no space between javascript (forum does it automatically)-->
</body>
</html>
|

July 21st, 2001, 11:00 AM
|
|
Clueless llama
|
|
Join Date: Feb 2001
Location: Lincoln, NE. USA
|
|
First, you missed a parameter in your open function call. The second parameter should be the oipened windows name. In this case you can use an empty string or you could use the name of the return variable(mailfriend).
Secondly, if you want to send the GET response to the opened window, you must add the search string to the URL in the open function call (see example).
Thirdly, you need to add a return false; in your onClick statement of your link. Links take the return value of a function called in their onclick event. If there is no return, it proceeds to execute the link itself.
Lastly, you do not need to set the focus of the new window as when you create it, it has system focus by default. Hope this helps!
PHP Code:
<html>
<head>
<script>
function popup_mailfriend()
{
mailfriend =
window.open(
'http://www.clanmisfire.com/index.php?section=sfs&topic=topic&subtopic=subtopic&subsubtopic=subsubtopic',
"",
'width=500,height=500,toolbar=0,scrollbars=0,location=1,statusbar=1,menubar=0,resizable=1,titlebar=1 ')
//mailfriend.focus();
}
</script>
</head>
<body>
<a href="http://www.clanmisfire.com"
onCLick='popup_mailfriend(); return false;'>Email this page to a friend</a>
</body>
</html>
Note: I used my site to see a working url.
Last edited by Nemi : July 21st, 2001 at 11:08 AM.
|

July 23rd, 2001, 09:08 AM
|
 |
CORNHOLIO!
|
|
Join Date: Jun 2001
Posts: 51
Time spent in forums: 3 h 35 m 9 sec
Reputation Power: 12
|
|
|
onCLick='popup_mailfriend(id = 1,2,3 ....); return false;'>Email this page to a friend</a>
could you do something like this? (not ment as an answer to the first question)
|

August 2nd, 2001, 11:31 AM
|
|
Divine Wind
|
|
Join Date: May 2001
Location: Mongo
Posts: 24
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Re: popup window doesn't work??(Javascript and some PHP)
Quote: Originally posted by Boszy
<script>
function popup_mailfriend()
{mailfriend = window.open('send_to_friend.php', 'width=500,height=500,toolbar=0,scrollbars=0,location=1,statusbar=1,menubar=0,resizable=1,titlebar=1 ')
mailfriend.focus();
}
</script>
</head>
<body>
<?
echo "<a href='", "send_to_friend.php?section=$section&topic=$topic&subtopic=$subtopic&subsubtopic=$subsubtopic";
echo "' onCLick='popup_mailfriend()'>Email this page to a friend</a>";
?>
|
The problem is that the query string is not being passed. The solution depends on how you want the rest of your page to work. As far as I can tell I'd just have:
<A HREF="#" onCLick="popup_mailfriend()">Email to friend</A>
and then use PHP to write the link location into the JavaScript function:
function popup_mailfriend() {
mailfriend = window.open('send_to_friend.php?section=<?php $section ?>&topic=<?php $topic ?>&subtopic=<?php $subtopic ?>&subsubtopic=<?php $subsubtopic ?>', ETC.
If the query string is visible in the URL you could use send_to_friend.php?<?php $QUERY_STRING ?>
If you are using the JavaScript by linking it in from an external file they you may need to send the query string like:
<A HREF="#" onCLick="popup_mailfriend(section=<?php $section ?>&topic=<?php $topic ?>&subtopic=<?php $subtopic ?>&subsubtopic=<?php $subsubtopic ?>)">
function popup_mailfriend(queryString) {
mailfriend = window.open('send_to_friend.php?'+queryString, ETC.
Anyway thats what your problem is and one of the solutions above should help (although it may need some fixing as I've not tested the code).
Emps
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|