Jump to content

page doesnt display whole if i use document.write


immunity

Recommended Posts

Hello i have 1 page movie.htmland 1 page movie.phpin movie.php i have displaying (correctly) a full page ( <html>....</html>)movie.html's body is empty i only have script onLoad() that make XMLhttpRequest and get Responed text from movie.php (so it get a whole page)var results = http.responseText;i type document.write(results);but it only load me 1 imageif i Press Refresh then the page will display correctly !(movie.html)is there anyway to avoid that? (user having to press refresh )

Link to comment
Share on other sites

I would suggest not using document.write(). Depending on where that code is called, it will either append the content to the current location in the body or it will completely overwrite the entire body.You'll most likely be better off using innerHTML on a container div.

Link to comment
Share on other sites

I would suggest not using document.write(). Depending on where that code is called, it will either append the content to the current location in the body or it will completely overwrite the entire body.You'll most likely be better off using innerHTML on a container div.
my problem was that i couldn't display adobe flash movies :) with innerHTML only with document.write()is there any secure way to use the document.write() ? i mean eraise everything in movie.html and overwrite how outpout of movie.php in the movie.html
Link to comment
Share on other sites

Using this article as a reference, I was able to embed a flash movie in a page using javascript and the innerHTML property on a div. This works for me in IE6, Firefox, and Opera.

<html><body><div id="test"></div><script>var html = "<object type=\"application/x-shockwave-flash\" data=\"http://www.w3schools.com/flash/fallingtext.swf\" width=\"400\" height=\"400\">";html += "<param name=\"movie\" value=\"http://www.w3schools.com/flash/fallingtext.swf\" />";html += "</object>";document.getElementById("test").innerHTML = html;</script></body></html>

Link to comment
Share on other sites

Yeah, embedding Flash with innerHTML works just fine. Take a look at the SWFObject library, the entire purpose of that library is to embed a Flash movie on the page and that's the method it uses to do it.

write: function(elementId){		if(this.getAttribute('useExpressInstall')) {			// check to see if we need to do an express install			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {				this.setAttribute('doExpressInstall', true);				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));				document.title = document.title.slice(0, 47) + " - Flash Player Installation";				this.addVariable("MMdoctitle", document.title);			}		}		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////			n.innerHTML = this.getSWFHTML();	  // see?//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////			return true;		}else{			if(this.getAttribute('redirectUrl') != "") {				document.location.replace(this.getAttribute('redirectUrl'));			}		}		return false;	}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...