Hi all,

I am messing around with Flash and have created a Flash NAV bar and was wondering how to implement the nav bar so it only loads once.

What I have is about 5 buttons that lead to other pages and the problem I am having at the moment is that the flash movie reloads whenever a new page opens and the web user then needs to click to activate the nav bar before they can navigate.

What I would like to see is that the nav bar loads once and then doesnt need to load on any other pages. Is my best option to use frames and have the nav bar in one frame and when the use clicks on a particular button the contect loads up on a second frame on the same page or is there a more modern way to do this.

Thanks
ikhan42

Dani AI

Generated

Short answer: avoid trying to force a Flash SWF to behave like a persistent app if you can — rebuild the nav as HTML/CSS/JS or use a single “shell” page that loads content into a container. and were right to flag the old IE click-to-activate and iframe ideas, but today Flash is end-of-life and unsupported in modern browsers, so moving away from Flash is the best long-term fix (Adobe Flash Player EOL).

If you can rebuild the nav:

  • Convert the menu to semantic HTML and use CSS for hover/animations and a tiny script for keyboard/accessibility. This gives SEO, accessibility, smaller payloads, and no plugin problems.
  • Use server-side includes or a template/layout system (PHP include, templating engine, etc.) so the nav is maintained centrally across pages.

If you must keep Flash temporarily:

  • Put the SWF in a persistent wrapper page (the “shell”) and load the rest of the site into another element (iframe) or fetch-and-inject content via XHR/fetch. That way the SWF never reloads because the browser never leaves the wrapper page. Be aware iframes hurt deep-linking and SEO unless you manage history.

Minimal example of a modern approach (shell + AJAX content loading + History API):

// simple content loader — pages must include <div id="content">...</div>
document.addEventListener('click', function(e){
  var a = e.target.closest('a');
  if(!a || a.target || a.hasAttribute('download')) return;
  if(location.origin !== new URL(a.href).origin) return;
  e.preventDefault();
  fetch(a.href, {credentials:'same-origin'}).then(r=>r.text()).then(html=>{
    var doc = new DOMParser().parseFromString(html,'text/html');
    var nc = doc.querySelector('#content');
    if(nc){ document.querySelector('#content').innerHTML = nc.innerHTML; history.pushState(null,'',a.href); }
    else location.href = a.href;
  }).catch(()=>location.href = a.href);
});
window.addEventListener('popstate', ()=>location.reload());

Notes: provide a no-JS fallback (full page links), handle same-origin policy, and plan to replace Flash entirely as browsers no longer support it.

Recommended Answers

All 2 Replies

Here are a few scripts available to get rid of the IE click to activate problem.

http://blog.deconcept.com/swfobject/

I'd suggest using SWFObject to handle the IE click to activate problem. As for reloading the page, you could load subsequent pages onto your main page using the IFRAME tag.

However, I would just toss it out there that maybe a Flash nav with the rest of the site content in HTML may not be the best way to go. Flash navs present some search engine optimization challenges and very often if you're dealing with an HTML site, having the nav in HTML ensures faster loading and no risk of a user not having the right version of Flash. Plus the usual rollover effects and the like which are done in Flash navigation can often be done in DHTML.

Believe me, I'm not dissing Flash (it's my bread and butter and I love it!), but sometimes it's not the best tool for the job.

Regardless, good luck and happy coding!

Best,

--eric

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.