View Full Version : Hoe can I detect and redirect?
MrLeN
03-14-2009, 10:52 AM
toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=550,left = 0,top = 0'
I have a JavaScript link, which opens a window with the above parameters.
How can I check to see if those parameters exist, and if they don't then the page will redirect?
Basically, I am just trying to make sure that people are viewing the page from the JavaScript link, and not viewing the page alone in a full browser screen.
rangana
03-14-2009, 12:47 PM
Try to check the window's width and height:
if (document.body.clientHeight!=500&&document.body.clientWidth!=800)
// Do some redirection here
Hope that helps.
MrLeN
03-14-2009, 12:53 PM
I finally managed with this code:
<?php echo '
<script type="text/javascript">
if( ((window.innerWidth) != \'800\') || ((window.innerHeight) != \'550\')) {
window.location = \'/share.php?v='.$_GET['v'].'\';
}
</script>'; ?>
Took me 4 hours just to write that -- pffft'..
..does the job though.
Thanks.
P.S. I am now trying to include the other parameters. ie: to detect if the statusbar is off, and the scrollbar etc..
EDIT DOH!!!!! My code doesn't work in ie... back to square 1... I'll try your code...
EDIT AGAIN Don't ask me how on earth this works.. I just scrounged around through javascript on Google and made a frankencode. It works in ie and firefox (somehow)..
<?php echo '
<script type="text/javascript">
if( document.documentElement &&
( (document.documentElement.clientWidth) != \'800\') || ((document.documentElement.clientHeight) != \'550\') ) {
window.location = \'/share.php?v='.$_GET['v'].'\';
}
</script>';
?>
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.