Bubbles
Bubbles

Reputation: 476

How can I call a JavaScript function embedded inside an html page using flex?

I know there are ways to invoke javascript inside the html wrapper template for the flex application using ExternalInterface, but is it possible to reference an external html page?

Upvotes: 0

Views: 555

Answers (3)

Santhosh Nayak
Santhosh Nayak

Reputation: 2288

i think its not possible to reference an external html page. you call function in AS3

ExternalInterface.call("MyFun"); 

in html wrapper file of flex within javascript you have to define function MyFun

 function MyFun()
    {
    ............
    ..........
    }

Upvotes: 0

Jacksonkr
Jacksonkr

Reputation: 32247

If you know the name of the other page/tab, use ExternalInterface to call a function on your current page which then calls a function on a "sister" page/tab. If the other page is not yours, or is on a different domain, you may be out of luck :(

How to call a function in separate named window:

new_window = window.open("page2.php", "window2", "height=120");
new_window.test();

Sample taken from: http://www.ozzu.com/programming-forum/call-javascript-function-from-another-window-t54343.html

Upvotes: 1

JeffryHouser
JeffryHouser

Reputation: 39408

JavaScript, generally, operates on the page that is loaded/renderered in a browser. It sounds like you want to run a JavaScript function on a page that isn't currently loaded/renderered in the browser. This would not be possible.

You might be able to do something with an embedded/hidden iframe in the html wrapper that loads your external page hidden from view. Then ExternalInterface should be able to access the HTML Wrapper which can access the iFrame.

Upvotes: 2

Related Questions