|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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!!! |
|
#2
|
||||
|
||||
|
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:
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() |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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! |
|
#5
|
|||
|
|||
|
it required some extra work but i have finally made it!
PHP Code:
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! |
|
#6
|
||||
|
||||
|
If you don't want Javascript errors at all, go for this one:
PHP Code:
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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > PHP and javascript: POP UPS |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|