|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
problem w/ simple script coming from Flash
Hi all,
I am using a javascript to open a new centered "pop-up"-window from Flash. It's simple and I haven't needed to use it for a long time. Now it doesn't work in Explorer (8). I have tried two different scripts actually, both originally coming from forums. It works fine in Safari, Firefox and Opera for MAC. It also works in Google Chrome on PC (haven't had a chance to try in Firefox/PC yet). In Explorer I get an: "Error in page" message in the status-field and when making an error-search in the webdeveloper tool, it displays "non-guilty argument" for this line: Code:
win = window.open(page,winName,config); Here is the code on the button in Flash: Code:
openPopupBUTTON.onRelease = function() {
getURL ("javascript:newWin('popupwindow.php','popupname','620','361','0','0')");
}
Code:
<script language="JavaScript" type="text/JavaScript">
<!--
function newWin(page,winName,w,h,scrollb,resize) {
var win=null;
centerWidth = (screen.width) ? (screen.width-w)/2 : 0;
centerHeight = (screen.height) ? (screen.height-h)/2 : 0;
config = 'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize+''
win = window.open(page,winName,config);
}
//-->
</script>
Is there anyone that can help?
|
|
#2
|
|||
|
|||
|
Help!
No one out there that knows what doesn't work?
The info I get from the status bar error message is this: Message: Invalid argument. Line: 32 Char: 1 Code: 0 URl: http//:the-url-to-the-phpdocument Line 32 is this one: Code:
config = 'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize+''
|
|
#3
|
|||
|
|||
|
A couple of points:
1) Get into the habit of declaring vars in the scope you need them. All your vars are global. Put 'var' before each. 2) Terminate commands with semi-colons. 3) Why do you implicitely add an empty string at the end of your command line? (...resizable+'') 4) I seem to recall an issue in IE with setting up command strings for pop-up windows rather than implicitely passing the individual parameters in the function invocation. Try that. |
|
#4
|
|||
|
|||
|
Thank you for answering!
I am basically a complete idiot when it comes to javascript. Can read it when it ressembles actionscript . And I have a hard time understanding your last point, possibly also because my understanding of English isn't perfect.I did add the semi-colons and have added var to the vars.. As far as I understand, the empty strings are there to receive the variables from the getURL action coming from Flash. Code:
openPopupBUTTON.onRelease = function() {
getURL ("javascript:newWin('popupwindow.php','popupname','620','361','0','0')");
}
|
|
#5
|
|||
|
|||
|
Did you try passing the pop-up window arguments directly inside the function, instead of preparing it as a var string? i.e.
Code:
var win = window.open(page,winName,'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize); Code:
var config = 'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize; var win = window.open(page,winName,config); Code:
getURL("javascript:window.open(page,"mywin",'height=100,width=100,top=0,left=0,scrollbars=0,resizable=0');
Code:
getURL("javascript:myfunc();"...
|
|
#6
|
|||
|
|||
|
Thanks! Will try, just have to find someone with a PC.. considering it's Saturday and I seem to have chosen my personal network out of the existance of MAC in their homes.. not PCs
|
|
#7
|
|||
|
|||
|
Hi again..
no nothing works as far as I have tried.. It does work to evoke the javascript from the actionscript like this: Code:
getURL("javascript:window.open(page,"mywin",'height=100,width=100,top=0,left=0,scrollbars=0,resizable=0');
It works to skip the var config and call the arguments directly in win but that doesn't work in Explorer (Explorer in Windows XP on Mac, mind you..) Nothing else seems to work. The strange thing is, the last argument, resizable, seems to be badly written since it lacks both the closing single quote and a +-sign. But if I put them there the window doesn't open in Mac either.. Code:
var win = window.open(page,winName,'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize); Code:
var win = window.open(page,winName,'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize+'); |
|
#8
|
|||
|
|||
![]() I think I am finally on the road with this one. Thanks for the help! I did this: Code:
<script language="JavaScript" type="text/JavaScript">
<!--
function newWin() {
var win=null;
var centerWidth = (screen.width) ? (screen.width-620)/2 : 0;
var centerHeight = (screen.height) ? (screen.height-362)/2 : 0;
var win = window.open('mynewwindow.php','newwindow','height='+362+',width='+620+',top='+centerHeight+',left='+centerWidth+',scrollbars=0,resizable=0');
}
//-->
</script>
Code:
button.onRelease = function() {
getURL ("javascript:newWin()");
}
But, if anyone knows there is something wrong in the code, please alert me since I am so unknowing in Javascript.
|
|
#9
|
|||
|
|||
|
I am now realizing that the script I wrote above doesn't work on all versions of Explorer. And strangely enough the failures are not consistent, i.e. it doesn't work on some computers with Windows XP with Explorer 8... On others it works..
Is there anyone out there that knows wht's wrong? Or is there ANY way I can open a chromeless centered window directly from its own script so that I don't have to use a javascript in the swf-file?? PLEASE HELP if possible..
|
|
#10
|
|||
|
|||
|
Is there a particular reason you need a new browser window? Why not use a lightbox type effect with a div that you populate, center, and make visible as needed?
|
|
#11
|
|||
|
|||
|
Partly because it wouldn't fit the rest of the site.. It's a small showreel playing in the new window and it should look like Quicktime rather than anything else.
What I should do really, is to make a flv instead and play it centered within the swf itself. Only, my client has bought a template I made quite a while ago and it's made with Actionscript 2.0. To use an flv I need to script in actionscript 3 which would mean a lot of changes to make for the site.. The client doesn't want to compress the mv4-file enough either to put it into the existing swf.. He wants to keep it at 11mb which means I have to stream it.. it takes too much time to download entirely before playing. |
|
#12
|
|||
|
|||
|
You can use flv content in AS2. We do that all the time at work. You could just as easily make a div containing a quicktime like player that "appears" when needed. That way you wouldn't have to touch your existing template and could reuse the component later (in fact there are a number of components free or otherwise that play flv content in either AS2 or AS3).
http://www.swinburne.edu.au/design/t...-Flash/ID-130/ |
|
#13
|
|||
|
|||
|
Thanks a bunch for the answer.
![]() I'll look into it in a little while.. However I haven't been able to publish anything with flv and AS2 combined.. |
|
#14
|
|||
|
|||
|
Hang on, making a div doesn't make a difference to me I think. I have an entire Flash site to work from, no html-content whatsoever (except the chromeless window and the window that holds the Flash-site). Which means the javascript is triggered from a button inside Flash. My problem is that I don't know how to trigger the chromeless centered window without using javascript inside Flash.. because then IE stops it. If I trigger it from a html-script in a php or html window it works fine. But maybe the answer is in the link you sent. Will look
|
|
#15
|
|||
|
|||
|
Can't seem to get the video from the link working.. will try again tomorrow.
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|