PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 17th, 2004, 06:02 PM
gabrop gabrop is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 4 gabrop User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question PHP and javascript: POP UPS

hello

i have this setup:

we have many sites which have tours with pop ups and i would like to implement a function or something in php like let's say www.mysite.com/join.htm?nopopup so that by using this very link, you won't get the pop ups.

right now we are triggering the pop ups with a regular javascript, but i would eventually change that with a php pop up.

basically i am looking for something that let us TRIGGER the pop ups according to the variable that is passed in the actual url.

input VERY appreciated, you can contact me via icq #132516819 or msn gabrio@teamperfecto.com

thanks a lot!!!

Reply With Quote
  #2  
Old August 18th, 2004, 01:41 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 997 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 14 h 26 m 27 sec
Reputation Power: 5
Send a message via ICQ to Itsacon
Simple, if the page is generated by PHP, just put an if statement around each line of Javascript that only displays it when the GET variable (not) set.

If the page isn't generated by php yet, you can still do this, just add php tags around it too. Code would then look like this:
PHP Code:
<?php
if(!isset($_GET['nopopup']))
echo / *
javascript line */;

?>

note: this is the code that DOESN'T display when the variable is set. to turn it around, remove the not operator (!) in front of isset()

Reply With Quote
  #3  
Old August 18th, 2004, 01:52 AM
gabrop gabrop is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 4 gabrop User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks bro, i just tried

<?php
if(!isset($_GET['nopopup']))
echo / *
javascript line */;

?>

but pops this error:

Parse error: parse error, unexpected '/', expecting ',' or ';' in /usr/home/**********/test.php on line 3

Reply With Quote
  #4  
Old August 18th, 2004, 02:03 AM
gabrop gabrop is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 4 gabrop User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i have made it.....

<?
if(!isset($_GET['nopopup']))
echo "<script language=\"JavaScript\">function xit()
{
open('http://*************,'xit','resizable=no,scrollbars=no,to olbar=no,location=no,directories=no,status=no,menu bar=no,width=380,height=425');
}\n";
echo "</script>";
?>

now i just need to change the function that i set to trigger it in the very code, since if i set onunLoad="xit()" in the body line, then it always load regardless if ?nopopup is set or not... then we're good to roll!

Reply With Quote
  #5  
Old August 18th, 2004, 02:51 AM
gabrop gabrop is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 4 gabrop User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb

it required some extra work but i have finally made it!

PHP Code:
<? 
if ($pop == false)
{
$pop_tog "xit";
}
echo 
"<script language=\"JavaScript\">function xit()
{
open('http://***********','xit','resizable=no,scrollbars=no,to olbar=no,location=no,directories=no,status=no,menu   bar=no,width=380,height=425');
}\n"

echo 
"</script>"
if (
$pop == true)
{
$pop_tog "pippo";
}
?> 

<html>
<head> 

</head>


<body onunLoad="<?php echo $pop_tog ?>()">

</body>
</html>


basically i have used a lil trick for the body statement, so that if the event is not triggered, then it shows up a 'pippo' var which is not defined, but that way javascript doesn't scream any error, i have just done some testing and everything works sweet ;-)

thanks anyway!

Reply With Quote
  #6  
Old August 18th, 2004, 03:58 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 997 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 14 h 26 m 27 sec
Reputation Power: 5
Send a message via ICQ to Itsacon
If you don't want Javascript errors at all, go for this one:

PHP Code:
<? 
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n<html>\n<head>\n";

if (
$_GET['nopopup'] != 1)
{
    echo 
"<script type=\"text/javaScript\">\n";
    echo 
"function xit()\n{\nopen('http://***********','xit','resizable=no,scrollbars=no,to olbar=no,location=no,directories=no,status=no,menu     bar=no,width=380,height=425');\n}\n"
    echo 
"</script>"

echo 
"</head>\n<body";
if (
$_GET['nopopup'] != 1)
    echo 
" onunload=\"xit()\"";
echo 
">\n";

# from here on normal page contents:
?>


</body>
</html>


This page always shows the popups unless youaccess it by: pagename.php?nopopup=1


PS: the reason my first script didn't work was because I accidentely had a space in the comment denominator (/*) which you had to replace with your JS anyway.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP and javascript: POP UPS


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT