problems to open url with parameters

  • sgalmeida
  • Born
  • Born
  • sgalmeida
  • Posts: 1

Post 3+ Months Ago

Greetings,

I'm (very) new to AS and I'mhaving some problems... :oops:
I have a popup page that presents a flash menu, and, when I select an item of the menu, the popup closes and the item is loaded on the parent page (the one that opened the flash popup page)

my AS code is this:

Code: [ Select ]
on (release) {
getURL("javascript:window.opener.location.href = 'pagina.php?parametro=valor';
if (window.opener.progressWindow){
  window.opener.progressWindow.close();
}
window.close();");
}
  1. on (release) {
  2. getURL("javascript:window.opener.location.href = 'pagina.php?parametro=valor';
  3. if (window.opener.progressWindow){
  4.   window.opener.progressWindow.close();
  5. }
  6. window.close();");
  7. }


this is a small script javascript that opens on parent page the URL and closes the child page. (by the way, Is there another way to call javascript functions within actionscript??)

my problem is that this work... just for the url = pagina.php and not the url = pagina.php?parametro=valor as it should be. From the caracter ?, actionscript "eats" the URL.

what is the problem? any help is wellcome .


thanks

Sérgio
  • IMMORTAL
  • Beginner
  • Beginner
  • User avatar
  • Posts: 45

Post 3+ Months Ago

Looks like you're missing a ") from

Code: [ Select ]
getURL("javascript:window.opener.location.href = 'pagina.php?parametro=valor';


Replace that line with

Code: [ Select ]
getURL("javascript:window.opener.location.href = 'pagina.php?parametro=valor'");


and see how it works.[/quote]
  • jhenigin
  • Newbie
  • Newbie
  • jhenigin
  • Posts: 5

Post 3+ Months Ago

Well, for one it wont compile like that.
Actionscript isn't as strict as javascript (or flexible, however you want to put it...) In essence the semicolons are optional, but the line breaks tell flash when the statement has ended. You can extend beyond a line break for formatting purposes by using the _ character. But it must be treated like a variable; out of quotes and you have to have a + in between . Example as such would get you closer:
Code: [ Select ]
on (release) {
getURL("javascript:window.opener.location.href = 'pagina.php?"+ _
+"parametro=valor'; "+_
+" if (window.opener.progressWindow){ "+_
+"  window.opener.progressWindow.close(); "+_
+" } "+_
+"window.close();");
}
  1. on (release) {
  2. getURL("javascript:window.opener.location.href = 'pagina.php?"+ _
  3. +"parametro=valor'; "+_
  4. +" if (window.opener.progressWindow){ "+_
  5. +"  window.opener.progressWindow.close(); "+_
  6. +" } "+_
  7. +"window.close();");
  8. }

However your javascript would not have the line breaks. I think it might still work, but to be a bit more elegant (or sloppy, however you put it...) you can add the line breaks into java with this:
Code: [ Select ]
on (release) {
getURL("javascript:window.opener.location.href = 'pagina.php?\n"+ _
+"parametro=valor'; \n"+_
+" if (window.opener.progressWindow){ \n"+_
+"  window.opener.progressWindow.close(); \n"+_
+" } \n"+_
+"window.close();\n");
}
  1. on (release) {
  2. getURL("javascript:window.opener.location.href = 'pagina.php?\n"+ _
  3. +"parametro=valor'; \n"+_
  4. +" if (window.opener.progressWindow){ \n"+_
  5. +"  window.opener.progressWindow.close(); \n"+_
  6. +" } \n"+_
  7. +"window.close();\n");
  8. }


At this point its ugly. At least to my eyes, alot of people like this, they can see it, and it doesn't make their eyes bleed. The moral of the story is to put your javascript in the html. You have 3 statements and an evaluation. certainly enough to jusify a function. So put your javascript where it belongs, in javascript and use
getURL("Javascript:JonSaidYourAFunctionNow()")

[blur]disclaimer: [/blur] I didn't check any of my work, but my theorys are most certainly my opinion and may be wrong [fade]even if does seem like agood idea at the time [/fade]

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 8 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.