Google Answers Logo
View Question
Q: Embed flash in HTML using Javascript ( Answered,   0 Comments )
Subject: Embed flash in HTML using Javascript
Category: Computers > Internet
Asked by: danners-ga
List Price: $10.00
Posted: 25 Jul 2003 08:36 PDT
Expires: 24 Aug 2003 08:36 PDT
Question ID: 235003
I need to embed a Flash file in my HTML page using Javascript - this
is in order to have the HTML in the page validated at - it doesn't like the embed src commands. I
have heard this is possible?
Subject: Re: Embed flash in HTML using Javascript
Answered By: theta-ga on 25 Jul 2003 12:04 PDT
Hi danners-ga,
   The <embed> tag was introduces by Netscape Navigator 2, but it was
never part of any HTML/XHTML specification. Therefore, code containing
this tag will never be successfully validated by the W3C validator.
There are a couple of ways to get around this problem:
        - You could use Javascript to add the embed tag to the HTML
        - You could use the object tag, which IS part of the
HTML/XHTML spec, to include the Flash movie.

- Using Javascript
   You can find a sample javascript template for embedding flash files
in HTML pages, here:
       - AzizAvenue: Validating W3C Standards with Flash
         You will note that the page itself contains a flash movie,
and is still XHTML compliant.

   The following Word document also provides a sample javascript
solution for your problem:
       - CASE STUDY:  How to make Macromedia Flash accessible
- Using the OBJECT tag
  Drew McLellan provides information on how you can create valid
standard compliant pages containing flash movies, in the following
        - A List Apart: Flash Satay
  If you use Flash MX for development, then you will find the
following template, based on the above article by Dave, useful:
        - Publishing XHTML 1.0 compliant code from Flash MX

Hope this helps.
If you need any clarifiacations, just ask!

Google/Google Answers Search Terms Used:
flash XHTML validate
javascript flash html validate

Request for Answer Clarification by danners-ga on 25 Jul 2003 13:46 PDT
Most of the examples given seem to deal with XHTML - will they also
work if I am trying to validate for 4.01 Transitional?
If I have a redirect script on my page for Netscape browsers (to a
page which I don't mind not being compliant) and then exclude the
<embed> tag in original page would that be a good way around it?

Clarification of Answer by theta-ga on 26 Jul 2003 09:43 PDT
Hi Dan,
  The techniques mentioned in the answer will work for HTML 4.01
validation also. For example, the following site uses the Javascript
method to embed flash in an HTML page, and still be valid HTML 4.01
       - Redman Jones

Redirecting Netscape users to a different non-compliant page would
also work, though I would not select it as the primary solution due to
the following reasons:
 - More Work. It will be upto you to maintain two versions of the same
page, and make sure that both contain the same updated information.
 - Page redirects: Most search engines are unable to follow page
redirects based on browser types, so your redirected page may not be
indexed by search engines.
 - Since the Netscape page would be invalid HTML 4.01, you would no
longer be able to claim HTML 4.01 compliance for your entire site.

My recommendation is that you try out either the Javascript or the
Flash satay method first. If these methods fail to satisfy your needs
for some reason, you can try out the page redirect method.

Hope this helps.
If you need any clarifications, just ask!
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy