1

I only have very limited control over a flash application. The only thing I can do is modify some links in an XML that it reads from.

I want to execute JS code based on the selected item in flash. I can link to something like: currentpage.html#some_anchor, but is there any way for me to detect the URL change from jQuery?

2 Answers 2

2

As alopix mentioned, you can use the HTML5 event, onhashchange, for IE8+, Chrome 5+ and Firefox 3.6+.

Since you're already using jQuery, you might want to take a look at this plugin by Ben Alman, which makes an implementation of the event available for unsupporting browsers. This makes it as simple as:

$(window).hashchange(function () {
    alert(window.location.hash);
});

You can also use ExternalInterface.call() to invoke a JavaScript function from Flash, which is probably a lot simpler for what you need, but doesn't help much if you don't have access to the Flash code.

Sign up to request clarification or add additional context in comments.

Comments

1

In modern browsers you can listen to the onhashchange-event.

$(function() {
    $(window).bind('hashchange', function() {
        // more here
    });
});

In IE<8 you have to set an interval and poll if the hash has changed.

var i = window.setInterval('checkforhashchange', 500);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.