Reputation: 572
In a php script, at certain point I need to show up a GreyBox popup:
<?php
if ($myvar==''){
?>
<script>
// I need to show mypage.php in a GreyBox popup when in here
GB_showCenter('Title', 'mypage.php' , 300, 620);
</script>
<?php
}
?>
The code above shows the popup when $myvar is empty but mypage.php never loads, the loading gif never stops turning and Firebug shows a "GB null" error pointing to loader_frame.html.
I also tried:
GB_show("Title", "mypage.php");
but same problem.
If I do:
<a href="mypage.php" onclick="return GB_showCenter('Title', this.href , 300, 620)">Click here</a>
somewhere in the page I have the popup with no problems so I know the files are correctly installed.
What am I doing wrong?
Thanks a lot!
Upvotes: 2
Views: 2651
Reputation: 717
I know this is ugly, but can you try if it works:
<?php
if ($myvar==''){
?>
<script>
pathArr = window.location.pathname.split('/');
path = window.location.protocol + "//" + window.location.host+"/";
for (i=1;i<pathArr.length-1;i++) path += pathArr[i]+"/";
GB_showCenter('Title', path+'mypage.php' , 300, 620);
</script>
<?php
}
?>
OK - another one (even uglier):
<?php
if ($myvar==''){
?>
<a href="mypage.php" onclick="return GB_showCenter('Title', this.href , 300, 620)" style="display: none;" id="myGreyBoxLink">Open GrayBox Window</a>
<script>
document.getElementById('myGreyBoxLink').onclick();
</script>
<?php
}
?>
Upvotes: 1