Click to See Complete Forum and Search --> : Expanding Window
lancehyde
12-05-2003, 05:24 PM
I am using the javascrip at http://javascript.internet.com/navigation/expanding-window.html
I am trying to edit this script so it activates when the page with this script is loaded. So the link is activated and a page comes up and expands.
Thanks, I am new at this.
Pittimann
12-06-2003, 02:20 AM
Hi!
Instead of using the link to click on provided with the script code -
<a href="http://javascript.internet.com/" onClick="expandingWindow('http://javascript.internet.com/');return false;">Open JavaScriptSource.com!</a>
put an onload= into your body tag:
<body onload="expandingWindow('http://javascript.internet.com/');return false;">
replacing the url with the one of your site...
Cheers - Pit
lancehyde
12-07-2003, 01:28 PM
All I need is the main window to close after the sub window apperars due to the script. I also thank Pittimann for helping me.
This is my current code.
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function expandingWindow(website) {
var heightspeed = 2; // vertical scrolling speed (higher = slower)
var widthspeed = 7; // horizontal scrolling speed (higher = slower)
var leftdist = 0; // distance to left edge of window
var topdist = 0; // distance to top edge of window
if (document.all) {
var winwidth = window.screen.availWidth - leftdist;
var winheight = window.screen.availHeight - topdist;
var sizer = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=1,height=1,scrollbars=yes");
for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) {
sizer.resizeTo("1", sizeheight);
}
for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) {
sizer.resizeTo(sizewidth, sizeheight);
}
sizer.location = website;
}
else
window.location = website;
}
// End -->
</script>
</HEAD>
<BODY onload="expandingWindow('http://cabinsandcamps.net');return false;">
</BODY>
</HTML>
Pittimann
12-07-2003, 02:07 PM
Hi!
Please check out the line:
---------------------------
sizer.location = website;
---------------------------
in your code and insert this:
---------------------------
window.close();
---------------------------
as the next line. The rest should be ok.
Please note: almost EVERY browser (including yours) will popup a confirm box asking the user, if the window really should be closed. If you can live with that, add the line I proposed.
If not - post again...
Cheers - Pit
lancehyde
12-07-2003, 02:16 PM
Thanks for helping
I searched the internet and found out you can add
javascript:window.opener=''; window.close();
and the main window will close without notice.
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function expandingWindow(website) {
var heightspeed = 2; // vertical scrolling speed (higher = slower)
var widthspeed = 7; // horizontal scrolling speed (higher = slower)
var leftdist = 0; // distance to left edge of window
var topdist = 0; // distance to top edge of window
if (document.all) {
var winwidth = window.screen.availWidth - leftdist;
var winheight = window.screen.availHeight - topdist;
var sizer = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=1,height=1,scrollbars=yes");
for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) {
sizer.resizeTo("1", sizeheight);
}
for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) {
sizer.resizeTo(sizewidth, sizeheight);
}
sizer.location = website;
javascript:window.opener=''; window.close();
}
else
window.location = website;
}
// End -->
</script>
</HEAD>
<BODY onload="expandingWindow('http://cabinsandcamps.net');return false;"></body>
</HTML>
Pittimann
12-07-2003, 02:26 PM
Hi!
You'll not succeed with that code!
Your script is not situated in the popup, but in the parent window...
Cheers - Pit
lancehyde
12-08-2003, 05:02 PM
Pittimann go to http://www.cabinsandcamps.net
and try it. It seems to work.