problem loading correct dynamic url using getURL

04-12-07, 07:53 PM
|
|
Wannabe Coder
|
|
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
problem loading correct dynamic url using getURL
I usedd this code but it never loads the correct webpage. Could any one help me fix this problem. It pops up window with localhost/undefined. I checked the url using trace and it has correct url but when it opens the window the url is not passed corectly and it pops up localhost/undefined instead.
actionscript Code:
myData = new LoadVars() myData.ref = this myData.load("http://localhost/script.php") myData.onLoad = function(succes){ if(succes){ getURL ("javascript:NewWindow=window.open(this.url,'newWin','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus(); void(0);"); trace(this.url); } else trace("Error loading data") } }
Last edited by Nico; 04-12-07 at 08:01 PM.
|

04-14-07, 04:56 AM
|
 |
Community Liaison
|
|
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
|
|
try this:
Actionscript Code:
getURL ("javascript:NewWindow=window.open("+this.url+",'newWin','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus(); void(0);");
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks
|

04-14-07, 04:08 PM
|
|
Wannabe Coder
|
|
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ureaded thanks . I keep getting http://localhost/+this.url+
in the popup window instead of passed url!! Using trace.url i see the url crectly but for some odd reason it does not load that url corectly in the browser!!! I tried all these and non worked:
this.url
'this.url'
"this.url"
'+this.url+'
"+this.url+"
\""+this.url+"\"
I even used echo "url=".$url; instead of echo "url=$url"; in php side and still didn't work!!
Last edited by method; 04-14-07 at 04:13 PM.
|

04-15-07, 04:26 AM
|
 |
Community Liaison
|
|
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
|
|
just a quick thought, but isn't url a reserved keyword (i just looked at the highlighted code, and it ended up in blue, instead of black). Try renaming the variable (inphp and flash) url2 will do, and see what happens.
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks
|

04-15-07, 09:50 AM
|
|
Wannabe Coder
|
|
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
unrealed i even tried url2 in both php and flash still same erro. Error shown in image
http://img224.imageshack.us/my.php?i...rgeturlyh1.jpg
Last edited by method; 04-15-07 at 09:52 AM.
|

04-15-07, 09:46 PM
|
 |
Community Liaison
|
|
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
|
|
I just tested your code on my pc, and it worked just fine, the only thing i changed was adding single quotes around the url:
ActionScript Code:
mybtn.onRelease = function (){ var url:String = "http://www.google.com"; getURL ("javascript:NewWindow=window.open('"+url+"','newWin','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus(); void(0);"); };
I tested this in Mozilla Firefox, and mozilla gave me the "the website tries to open a popup" notification
Cheers
PS: are you dutch speaking? cause i found the same code on a Dutch forum, named Flashfocus. This is the url of the thread: http://www.flashfocus.nl/forum/showt...+nieuwe+window
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks
|

04-16-07, 03:05 AM
|
|
Wannabe Coder
|
|
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Unreal. Thanks for testing the code. My main goal is to load dynamic url from db and opens it up in a new web browser every few seconds . i don't want to create buttons to load url!!
I followed your example and non of them work. could you look at these 2 version of the code and let me know what i am doing wrong. i keep getting this error:
This is the hardcoded version of url but still does't load the google in the browser
ActionScript Code:
function loadData(){ myData = new LoadVars() myData.ref = this myData.load("http://localhost/geturlfromdb.php") myData.onLoad = function(succes){ if(succes){ var url:String = "http://www.google.com"; getURL ("javascript:NewWindow=window.open('"+url+"','newWin','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus(); void(0);"); } else trace("Error loading data") } } a = setInterval(loadData, 9000) //1000 = 1 second
This version gets url form mysql via php. this.url holds the url .I used trace and saw that url get passed corectly to flash but flash can't load the url in the browser!!
i tried both var url:String = "this.url2"; and var url:String = this.url2;
ActionScript Code:
function loadData(){ myData = new LoadVars() myData.ref = this myData.load("http://localhost/geturlfromdb.php") myData.onLoad = function(succes){ if(succes){ var url:String = "this.url2"; //trace(this.url2); getURL ("javascript:NewWindow=window.open('"+url+"','newWin','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus(); void(0);"); } else trace("Error loading data") } } a = setInterval(loadData, 9000) //1000 = 1 second
Last edited by UnrealEd; 04-16-07 at 04:00 AM.
Reason: please use the [highlight=ActionScript] wrapper when posting ActionScript code
|

04-16-07, 04:06 AM
|
 |
Community Liaison
|
|
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
|
|
i'm not sure for 100%, but i think i've found the problem:
Javascript Code:
"javascript:NewWindow=window.open('"+url+"','newWin','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus(); void(0);"
In firefox it might work like this, but in IE i think you have to give the same name to the window as you pass in the second parameter of the window.open function
so this might work i think:
Javascript Code:
"javascript:newWin=window.open('"+url+"','newWin','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); newWin.focus(); void(0);"
If the first code isn't working either, i think the problem is in IE and not in Flash or PHP.
in your second code:
ActionScript Code:
var url:String = "this.url2";
will only pass this.url2 to the url variable, and not the value of this.url2.
ActionScript Code:
var url:String = this.url2;
this should do it (by default the returned variable is a string, so you don't have to cast it to string, like you do in php)
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|