-
Ok, so seems like some folks understand how the java works for poping a new window out of Flash and some still don't. Thought I would take everyone through the code and try to explain what each piece is and how it is used.
AGAIN, thanks go to the good folks at http://www.polar-lights.com who provided the base code for me to pass on here.
Browsers
I have tested these window methods on:
- IE 5.0 and 5.5
- Netscape 4.7
- Windows and Mac
The Code
You are using a getURL command to call a javascript function: window.open
getURL ("javascript:window.open('FileName','WindowName',' Variables'); void(0);");
}
FileName
Your file name is the name of the HTML, executable, or other file that you want to open in your window. Usually it is an HTML file. The file either needs to be an Absolute Reference - http://www.yoururl.com, or it needs to be a file residing in the same directory as your base file.
getURL ("javascript:window.open('http://www.flashkit.com','WindowName','Variables'); void(0);");
}
or
getURL ("javascript:window.open('myurl.html','WindowName' ,'Variables'); void(0);");
}
WindowName
Your window name is the named reference for the window that you will open. The only restriction that I know if here is the name cannot contain any spaces. So if your window is to be named "Welcome to Flashkit", you would put "WelcometoFlashkit", or "Welcome_to_Flashkit". The window name can be used to control the window and send commands to that window.
Variables
Your variables are your window height, width, and controls. The variables are listed separated by commas and no spaces. The variables that I am aware of that can be set are:
- height=### - denotes the height of the window in pixels.
- width=### - denotes the width of the window in pixels.
- toolbar=yes/no - denotes if there will be a toolbar on the newly opened window. Set this to yes if you want one - no if you don't.
- menubar=yes/no - denotes if there will be a menubar. Set this to yes if you want one - no if you don't.
- scrollbars=yes/no - denotes if there will be scrollbars or not. Set this to yes if you want one - no if you don't.
- resizable=yes/no - denotes if the user can change the size of the window by dragging on the lower right corner or not.
- location=yes/no - The location bar is the space at the top of the browser window where the page URL is displayed.
- directories=yes/no - This is the bar at the top of the browser window that has the bookmarks and such.
- status=yes/no - The status bar is the area at the very bottom of the browser screen that tells you "Document Done".
- left=### - This positions the window a certain number of pixels from the left side of the screen.
- right=### - This positions the window a certain number of pixels from the right side of the screen.
void(0);");
The void statement keeps the browser from corrupting or changing your base window - and we put it there because Illya from Polar-Lights says we have too!
Put it together
These examples are Flash 5, but the concept is the same for Flash 4, just slight differences in syntax:
300x400 window with toolbars, scrollbars, and status:
on (release) {
getURL ("javascript:window.open('http://www.flashkit.com','Welcome_To_FlashKit','width=300 ,height=400,top=0,left=0,toolbar=yes,scrollbars=ye s,resizable=no,menubar=no,status=yes,directories=n o,location=no'); void(0);");
}
600x800 window with toolbars, menubar, resizable, set 50 pixels from the left edge and 100 pixels from the top
on (release) {
getURL ("javascript:window.open('http://www.flashkit.com','Welcome_To_FlashKit','width=800 ,height=600,top=100,left=50,toolbar=yes,scrollbars =no,resizable=yes,menubar=yes,status=no,directorie s=no,location=no'); void(0);");
}
[Edited by GreatGooglyWoogly on 02-15-2001 at 05:47 PM]
-
Centering your Pop-up Window
Here is another modified polar-lights script for poping your window in the center of the screen. The variables 'varHeight''varWidth' and your set Height/Width should match for this to work properly:
on (release) {
varHeight="300"
varWidth="400"
getURL ("javascript:window.open('http://www.flashkit.com','Welcome_To_FlashKit','width=400 ,height=300,top='+((screen.availHeight/2)-(" add varHeight/2 add"))+',left='+((screen.availWidth/2)-(" add varWidth/2 add "))); void(0);");
}
-
The Supreme Shaman and Keeper of Polar Lights
Hi !
Thanks for your thanks - i'll try to keep putting something interesting on my page in future
Just few words about all that things:
- First of all it was not my idea about void(0) - it is just standard Java Script "good style to use" operator. For example it is possible to read about it at
http://developer.netscape.com/docs/m...ps.htm#1042625
- In most browsers (something near 99% of all current browsers) default value of all "yes/no" variables is "no" so you can drop "resizable=no,menubar=no,directories=no,location=n o"
- If you want to change contents of existing pop-up, it is better to declare pop-up window as JS object and open it first time like
someObjName=window.open('url.htm','windowName',... ..
after it if you of course may say for changing contents
window.open('url2.htm','windowName',.....
using same 'windowName', but it will work not in all browsers. Much better solution is saying from parent page or any other pop-up window
getURL ("javascript:window.someObjName.location.href='url 2.html'; void(0);");
- If you want to have several pop-ups, open all ot them like
someObjName=window.open('url.htm','windowName',... ..
and use different "someObjName" and "windowName" for each window.
- If you want your pop-up window to stay on top all time, you have to edit HTML code - sorry Just put in <body tag
onBlur="self.focus();"
But it will work not in all browsers and not under different conditions ...
- And at last if you want to call parent window from pop-up, for example make Get Url in parent window from pop-up, just say
getURL ("javascript:window.opener.location.href='someurl. html'; void(0);");
-
Again Ilya, great stuff and thanks!
-
Thanks again GreatGooglyWoogly and Ilya
One more q ... for Centering your Pop-up Window, will it work for flash 4? if yes, how do we put in the script?
Thanks
-
POR FIN!!!!!!!!
MUCHISIMAS GRACIAS POR COLOCAR ESTE SCRIPT, NO TIENES IDEA CUANTO TIEMPO HE PASADO BUSCANDO AYUDA.
ATENTAMENTE,
LUIS MEZA
-
Hmm. I can't get this to work at all! I've been using another JS technique for opening windows without a problem, but I need a way of opening centred windows. What gets pasted in the HTML head for this to work?
-
Nothing goes into the HTML head. This is code that goes into your button only.
-
serial loser
And once again The GreatGooglyWoogly strikes. I have been trying to get this to work for about 2 months. I manage to get it to work when i use a regular html link from dreamweaver (http://members.fortunecity.com/antipipe), but not from a button with in flash. I hope this will finally be my answer to a huge problem in my life So thanks again....
[Edited by Progenitor on 03-22-2001 at 05:45 PM]
-
Thanks GGW, I had to actually paste your script and tear my old one out to get it to work.... I've been loooking for this one for a while!
Now: is it possible to do a full-screen pop-up window from flash in all major browsers?
-
serial loser
(one day later & really stressed!!!!!) What the F%$# am i doing wrong???? I just cannot get this to work! Here's the scenario:
I have an intro-movie1. I wnt to link it to my portmovie-movie2. I double click on the button in my intro. Go to actions, click on get url & put the following in the properties tab, or whatever you call it:
('portmovie.html,'myPORTFOLIO','width=8700,height= 500,top=50,left=50,toolbar=no,scrollbars=no,resiza ble=no,menubar=no,status=yes,directories=no,locati on=no'); void(0);"); }
So i publish & test....AND NOTHING!!!! what am i doing wrong???? Can anybody help me...PLEASE!!!!! I'm deperste here!!!!!
-
Originally posted by Progenitor
(one day later & really stressed!!!!!) What the F%$# am i doing wrong???? I just cannot get this to work! Here's the scenario:
I have an intro-movie1. I wnt to link it to my portmovie-movie2. I double click on the button in my intro. Go to actions, click on get url & put the following in the properties tab, or whatever you call it:
('portmovie.html,'myPORTFOLIO','width=8700,height= 500,top=50,left=50,toolbar=no,scrollbars=no,resiza ble=no,menubar=no,status=yes,directories=no,locati on=no'); void(0);"); }
So i publish & test....AND NOTHING!!!! what am i doing wrong???? Can anybody help me...PLEASE!!!!! I'm deperste here!!!!!
Are you using Flash 4 or 5? And I assume that you had:
getURL ("javascript:window.open
Before your:
('portmovie.html,'myPORTFOLIO','width=8700,height= 500,top=50,left=50,toolbar=no,scrollbars=no,resiza ble=no,menubar=no,status=yes,directories=no,locati on=no'); void(0);"); }
Did you? Also, width 8700? Is it a horizontal scroll?
-
serial loser
Are you using Flash 4 or 5? And I assume that you had:
getURL ("javascript:window.open
Before your:
('portmovie.html,'myPORTFOLIO','width=8700,height= 500,top=50,left=50,toolbar=no,scrollbars=no,resiza ble=no,menubar=no,status=yes,directories=no,locati on=no'); void(0);"); }
Did you? Also, width 8700? Is it a horizontal scroll? [/B][/QUOTE]
Yes, I do have "getURL ("javascript:window.open" before the rest.
I'm using flash 4. Width=8700, should have been width=700. If you like you can take a look at what I'm trying to do at:
http://members.fortunecity.com/antipipe
Any help is much appreciated. You will see that I have an html link at the bottom which does what I'm trying to do from my swf. I did it in dreamweaver through the behaviours palette.
Thanks,
A...
-
AH HA! For Flash 4, your code looks like this:
On (Release)
Get URL ("javascript:window.open('http://www.flashkit.com','NameofWindow','width=800,height =600,top=0,left=0'); void(0);")
End On
-
serial loser
so would this be right?
So i click on actions, on event release. Then get url.
So it will look like this:
On (Release)
Get URL ("javascript:window.open('portfolio.html,'myPortfo lio','width=700,height=500,top=0,left=0'); void(0);")
End On
In the window where you put the code, do you need to put get url as well?
do I make any sense at all???
Does there need to be anything in the head of the html????
-
No, nothing in the HTML file at all - that is the beauty of this code - single step in flash only.
On (Release)
Get URL ("javascript:window.open('portfolio.html,'myPortfo lio','width=700,height=500,top=0,left=0'); void(0);")
End On
You will need another ' at after portfolio.html:
'portfolio.html',
Let me know if you have any further trouble making it work.
-
serial loser
Originally posted by GreatGooglyWoogly
No, nothing in the HTML file at all - that is the beauty of this code - single step in flash only.
On (Release)
Get URL ("javascript:window.open('portfolio.html,'myPortfo lio','width=700,height=500,top=0,left=0'); void(0);")
End On
You will need another ' at after portfolio.html:
'portfolio.html',
Let me know if you have any further trouble making it work.
If this works then I'll forever be in debt to you...actually i still owe you - you helped me with my preloader too, quite some time back!!!
So all i do is just put the following in the space provided once i've clicked on get url:
Get URL ("javascript:window.open('portfolio.html','myPortf olio','width=700,height=500,top=0,left=0'); void(0);")
End On
-
Actually, what would be in your getURL window would be something like this:
javascript:window.open('http://www.flashkit.com','NameofWindow','width=800,height =600,top=0,left=0'); void(0);
Flash 4 will add the parens and the quotes. In Flash 5, you could just code it straight - much easier. But flash 4 makes you work within its actionscript template - kind of a pain.
-
serial loser
Originally posted by GreatGooglyWoogly
Actually, what would be in your getURL window would be something like this:
javascript:window.open('http://www.flashkit.com','NameofWindow','width=800,height =600,top=0,left=0'); void(0);
Flash 4 will add the parens and the quotes. In Flash 5, you could just code it straight - much easier. But flash 4 makes you work within its actionscript template - kind of a pain.
thanks!! will let you know how it goes!!!
-
Thanks soo much!
OMG thanks soo much for the input
Ive been trying to sort this out for weeks now, and no one would give me a straight answer.
I used a behaviour in Dreamweaver to make my flash site open in a window with no buttons, menus etc but couldnt figure out how to open another window the same from flash.
Like progenitor Im using flash 4 and was under the asumption that the get url was looking for the javascript in the HTML splash page. Your tutorial was really good and it works fine now.
Its always the basic stuff that goes over your head..
On the subject of centering the popup window...
on (release) {
varHeight="300" <== How do I add these two lines
varWidth="400" <==
getURL ("javascript:window.open('http://www.flashkit.com','Welcome_To_FlashKit','width=400 ,height=300,top='+((screen.availHeight/2)-(" add varHeight/2 add"))+',left='+((screen.availWidth/2)-(" add varWidth/2 add "))); void(0);");
}
can you please look closely at this script: after top= is there sposed to be a ' ? and is there sposed to be 3))) at the end?
Let me know
thanks
Coz
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|