Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

NavigatetoURL problem with Javascript call

Posted on 2009-02-22
3
Medium Priority
?
3,640 Views
Last Modified: 2012-06-21
I have a flash file and using NavigatetoURL to get a link from an XML file and load it into a div container. The Javascript function I am using came from DynamicDrive and is called ajaxPage. The XML reads fine and I get the information I need; the problem I have is an an error message relating to line 30 in my Javascript function: "Access Denied"

line 30 = page_request.open('GET', url+bustcacheparameter, true)

Adobe website sdays the following but I do not think it pertains to my setup as I am running this on my local pc under IIS;

"For local content running in a browser, calls to the navigateToURL() method that specify a "javascript:" pseudo-protocol (via a URLRequest object passed as the first parameter) are only permitted if the SWF file and the containing web page (if there is one) are in the local-trusted security sandbox. Some browsers do not support using the javascript protocol with the navigateToURL() method. Instead, consider using the call() method of the ExternalInterface API to invoke JavaScript methods within the enclosing HTML page.

In Flash Player, and in non-application sandboxes in Adobe AIR, you cannot connect to commonly reserved ports. For a complete list of blocked ports, see "Restricting Networking APIs" in the security chapter of the Programming ActionScript 3.0 book.
"

I wonder if anyne can help as I have found no answers on the internet at all... :(
AS3
------
function onMouseClickEvent(event:Event)  {  
trace("IN: "+glo.myURLvar.myURL);
var websiteURL:String = "Javascript:ajaxpage('" + glo.myURLvar.myURL + "','ajaxcontent');"
trace(websiteURL);
var request:URLRequest = new URLRequest(websiteURL);
navigateToURL(request, '');
}
 
-----------
JS Code
-----------
function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

Open in new window

0
Comment
Question by:clearchannel
  • 2
3 Comments
 
LVL 10

Assisted Solution

by:Bane83
Bane83 earned 1400 total points
ID: 23706694
Verify that the url is correct.  The XMLHttpRequest object has a bad habit of spitting out "Access denied" on bad URLs.  Stupid error to throw, but whatcha gonna do, right?  Be sure that the url is properly cased as well as I've seen situations where this thing hiccups over that as well (ie:  www.mysite.com/test.html vs www.mysite.com/Test.html)
0
 

Author Comment

by:clearchannel
ID: 23707172
When I trace the URLs they're correct though so I do not understand it :(
The URls I am using are local and fully qualified domina URLS so it should work for those at least.

Could it not be something to do with the NavigatetoURL command I am using and the string containng the javascript call?
0
 

Accepted Solution

by:
clearchannel earned 0 total points
ID: 23712073
I sort of figured out the issue;for some reason cross-domain URLs in the way I have used them in the Javascript call is invalid. So I have had to use realtive pages in my XML file and then quickly redirect those pages to the external websites. to scoot round the problem.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question