JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 21st, 2001, 10:02 AM
Boszy Boszy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Netherlands
Posts: 8 Boszy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 9 m 13 sec
Reputation Power: 0
Send a message via ICQ to Boszy
Question 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 -

Reply With Quote
  #2  
Old July 21st, 2001, 10:56 AM
DJdrenaline DJdrenaline is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2001
Location: Toronto, Ontario, Canada
Posts: 631 DJdrenaline User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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>

Reply With Quote
  #3  
Old July 21st, 2001, 11:00 AM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 39 m 5 sec
Reputation Power: 116
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.

Reply With Quote
  #4  
Old July 23rd, 2001, 09:08 AM
Ricochet's Avatar
Ricochet Ricochet is offline
CORNHOLIO!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 51 Ricochet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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)

Reply With Quote
  #5  
Old August 2nd, 2001, 11:31 AM
Emperor Emperor is offline
Divine Wind
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Mongo
Posts: 24 Emperor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Emperor
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > popup window doesn't work??(Javascript and some PHP)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap