Question about combining some PM pop-up features
-----
| Author | Message | |
|---|---|---|
|
Carter |
||
| Tue Nov 06, 2007 8:16 pm Post subject: Question about combining some PM pop-up features | ||
|
Hi Thoul, I was wondering if you could help me tweak some small phpbb features a little.
It's pretty easy - I just need to know if combining these two little features is possible - it certainly doesn't seem like advanced javascript if I can decode it. Here's the current javascript for centering the PM popup window for my board: Code: <script language="Javascript" type="text/javascript">
<!-- var win = null; function phpBBPOPUP(mypage,myname,w,h,scroll){ LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable' win = window.open(mypage,myname,settings) } if ( {PRIVATE_MESSAGE_NEW_FLAG} ) { phpBBPOPUP('{U_PRIVATEMSGS_POPUP}', '_phpbbprivmsg', '400', '225', 'no');; } //--> </script> Seems fairly simple, just defines a formula that centers the window and then calls the function if the PHP variable for the user is set to allow the PM popup. Now, here is the code that I want to include - it creates a floating table that will display if the normal (uncentered) phpbb window doesn't appear: Code: <!-- BEGIN switch_enable_pm_popup -->
<table id="new_pm_popup" class="forumline" border="0" cellspacing="1" cellpadding="4" style="position: absolute; top: 25%; left: 25%; height: 125px; width: 400px; display: none;"> <tr> <td valign="top" class="row1" align="center"> <br /> <span class="gen">{L_PRIVATEMSG_NEW}<br /><br />{L_MESSAGE}</span><br /><br /> <span class="genmed"><a href="" onClick="getElementById('new_pm_popup').style.display = 'none'; return false;" class="genmed">{L_CLOSE_WINDOW}</a></span><br /><br /> </td> </tr> </table> <script language="javascript" type="text/javascript"> <!-- if ( {PRIVATE_MESSAGE_NEW_FLAG} ) { pmWindow = window.open('{U_PRIVATEMSGS_POPUP}', '_phpbbprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400'); if (!window.pmWindow) { document.getElementById('new_pm_popup').style.display = 'inline'; } } //--> </script> <!-- END switch_enable_pm_popup --> Now, what I was playing around with is a way to combine those two functions to allow a centered PM window, but if that gets blocked, allow the floating table to display. But since the mod I want to include is designed to replace the old phpbb pop up function (which wasn't centered), I'm not sure how to replace or combine the two. This was my best attempt: Code: <!-- BEGIN switch_enable_pm_popup -->
<table id="new_pm_popup" class="forumline" border="0" cellspacing="1" cellpadding="4" style="position: absolute; top: 25%; left: 25%; height: 125px; width: 400px; display: none;"> <tr> <td valign="top" class="row1" align="center"> <br /> <span class="gen">{L_PRIVATEMSG_NEW}<br /><br />{L_MESSAGE}</span><br /><br /> <span class="genmed"><a href="" onClick="getElementById('new_pm_popup').style.display = 'none'; return false;" class="genmed">{L_CLOSE_WINDOW}</a></span><br /><br /> </td> </tr> </table> <script language="javascript" type="text/javascript"> <!-- var win = null; function phpBBPOPUP(mypage,myname,w,h,scroll){ LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable' win = window.open(mypage,myname,settings) } if ( {PRIVATE_MESSAGE_NEW_FLAG} ) { phpBBPOPUP('{U_PRIVATEMSGS_POPUP}', '_phpbbprivmsg', '400', '225', 'no'); if (!window.phpBBPOPUP) { document.getElementById('new_pm_popup').style.display = 'inline'; } } //--> </script> Unfortunately, that doesn't particularly work...it won't display the table if the pop-up is blocked. There was another version I played around with that would display both no matter what - I want the floating table to display ONLY if the pop-up is blocked, so having them appear even if the pop-up isn't blocked is rather annoying. Got any insight? |
||
|
Thoul |
||
| Thu Nov 08, 2007 12:17 am Post subject: Re: Question about combining some PM pop-up features | ||
|
To my knowledge, there is no way to detect if a popup window was blocked. Given how prevalent popup blocking browsers and add-ons have become, I recommend dropping the popup entirely and just using the table.
|
||
|
Carter |
||
| Thu Nov 08, 2007 7:36 pm Post subject: Re: Question about combining some PM pop-up features | ||
|
Really? Because the second set of javascript I posted really does just that, at least when I tested it out:
Code: pmWindow = window.open('{U_PRIVATEMSGS_POPUP}', '_phpbbprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
if (!window.pmWindow) { document.getElementById('new_pm_popup').style.display = 'inline'; } I wonder if there isn't a way to combine the two. It seems possible, but I'm not a javascript expert. The floating table is nice, but I like the pop-up as well. Maybe I'll compromise and make a floating table that just appears in the center of the screen. Might be a more elegant solution. |
||
Page 1 of 1