How to open Named Anchor links in flash

About anchor links

In html you can link to a speciffic area of a html page by adding anchors, for example this link will point you to the “solution” area of this page; you link to an area of a page (to an anchor) by adding # after file name followed by the anchor name, e.g: products.php#product4 or just #product4 if destination is on same page.

The ‘namedanchor’ (destination) is written like this in the html code:

<a name=”solution” id=”solution”></a>

The flash issue

When you want a flash button to open a Named Anchor inside the html page normally you would think that the link can be open by something like this:

getURL(‘products.php#product4’);

but the above will not work because of some flash limitations

Solution

Write a really short javascript in the html page and set the getURL from flash to trigger that JavaScript.

Write this function in <head> … </head> area of html code:

1. <script language=“JavaScript”>
2. function openNewWindow(URLtoOpen, windowName, windowFeatures){ 
3. newWindow=window.open (URLtoOpen, windowName, windowFeatures);
4. }
5. </script>

Modify getURL actions from flash to call the above JavaScript:

 
1. getURL(javascript:openNewWindow(‘anchor_test.html#title2′,’_parent’)”;

This solution was tested and worked in both Internet Explorer and Mozilla Firefox type browsers.

Download Sample Files >

Tutorial Source: macromediahelp.com & adobe.com
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s