What functions does Javascript use to modify html?
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 开发者_JAVA技巧600 lines of code, so its difficult to analyse each line. Also im kind of a JS newbie.
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
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";
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.
精彩评论