PDA

View Full Version : Possible complex task: Can you resize the current page, then open a new URL in it???


Chad Roe
05-19-2006, 11:16 PM
Can you resize the current page, then open a new URL in it???

Ok, here's the deal...

I have an index page (index.php) inside one of my sub directories, that redirects anyone who tries to access the root of that directory (http://www.here.com/dir/), to a main page. All of the pages in that sub directory are sized for popups, and shouldn't be viewed full-size.

Is there any way to automatically resize that window and then open the main page inside of it? I know I can use my JavaScript PopUp link to automatically open the main page in it's own, correct size window, but that leaves the full-size index window open in the background.

If I can not automatically resize the window and then open the main page inside of it, is there a way to automatically close the window before automatically popping up the correctly sized main page?

Chad Roe
05-20-2006, 12:39 AM
Ok, just a little update...

I did some more research and found a nice little piece of JavaScript code that does exactly what I want, but it needs a tweak to be perfect. I would prefer to do this in PHP (anyone know how?), but this will work for now.

The tweak I need is to check the window's current size when it loads, and resize it if it needs to be. This way, it won't auto-resize if it is already the correct size. The reason this is a problem, is because this JS code goes in the top of every popup page (i actually use a remotely linked file for my scripts), and resizes the window on every load, even if it is popped up in the correct size to begin with. This slows everything down and is unnecessary. Here is the JS code (To redirect, I use small script)...



<script type='text/javascript'>

var top = 0 //Set top
var left = 0 //Set left
var width = 500 //Set width
var height = 300 //Set height
var name = "admin" //Set window name

if(document.location.search=='') {
newwin=window.open(document.location + "?newwin=true", name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no, width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
self.close()
}

</script>