views:

70

answers:

3

In a HTML/Javascript webpage, the javascript file takes the body of the html, renders the contents in the tag in Flash, and displays the flash content. The page is not flash, it is still Html, but the javascript must be modifying it to display it in Flash. What i want to know is what functions/methods does Javascript use to modify the Html page it is a part of? I know of one - document.write(). Are there any others?

P.S - The javascript file contains about 600 lines of code, so its difficult to analyse each line. Also im kind of a JS newbie.

+3  A: 

Flash files are embedded in HTML page using the <object> tag and javascript has nothing to do with this.

See Flash Embedded in HTML

If by modifying HTML you mean altering the DOM then javascript has numerous functions to do this like adding and removing document elements, changing the properties of existing DOM elements etc.

For a detailed reading

JavaScript and HTML DOM Reference

rahul
But, in the resulting html file that is displayed, the object tag is not used.
Pranav
@Pranav - are you sure you're seeing the actual rendered HTML (via DOM Inspector etc.), and not the original source (via View Source)? The latter wouldn't contain it, because it's inserted by SWFObject during run-time
K Prime
You are right, will look at it with the dom inspector...
Pranav
+2  A: 

Flash can be inserted using different methods. SWFObject is one of the popular ones.

If it is not using libraries like SWFObject or jQuery, look for things like createElement, appendChild, getElementById, innerHTML etc.

var obj = document.createElement("embed");
obj.appendChild(necessary_children_to_embed_flash);
document.body.appendChild(obj);

//or
element = document.getElementById("elements_id");
element.innerHTML = "<p>A paragraph</p>followed by html to insert flash";
Amarghosh
Yes, the javascript file is using SWFObject.
Pranav
+1 for element.innerHTML
infant programmer
Thanks. But be warned that `innerHTML` is generally not considered as a good way to modify DOM http://www.google.com/search?q=innerhtml+is+evil
Amarghosh
+1  A: 

I can only guess you are wanting to pass additional parameters to the flash object tag that gets created. Since you are using SWFObject, you can use it's interface to inject any appropriate parameters for use in your Flash. If you have specific questions regarding SWFObject's use, I'd suggest creating a followup question separately.

To answer the question at hand. innerHTML, outerHTML, getElementById, getElementsByTagName, and many others exist along with JavaScript libraries that simplify document object model selection, modification and insertion. I would suggest the DOM inspector in Firebug for Firefox, or the F12 tools in IE8 to further examine the DOM after actions by SWFObject.

Tracker1