Hi there,
I have a html site with three div tags, I want to be able to load an SWF into one of the div’s via a html button.
I have looked into using AJAX and have this solution:
[SIZE=1][COLOR=Blue]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=“content-type” content=“text/html; charset=utf-8” />
<title>Kristian Brace : Portfolio</title>
<meta name=“keywords” content="poplar farm, holiday cottages, last minuet deals, cheap holidays, somerset, weston super mare, holiday, cottages, " />
<meta name=“description” content=“Poplar Farm Holiday Cottages offer first class holidays in Somerset at competitive rates” />
<link href=“default.css” rel=“stylesheet” type=“text/css” />
<script type=“text/javascript”>
/***********************************************
- Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
- This notice MUST stay intact for legal use
- Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain=“http://”+window.location.hostname
var bustcacheparameter=""
function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject(“Msxml2.XMLHTTP”)
}
catch (e){
try{
page_request = new ActiveXObject(“Microsoft.XMLHTTP”)
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? “&”+new Date().getTime() : “?”+new Date().getTime()
page_request.open(‘GET’, url+bustcacheparameter, true)
page_request.send(null)
}
function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf(“http”)==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}
function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments*
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement(‘script’)
fileref.setAttribute(“type”,“text/javascript”);
fileref.setAttribute(“src”, file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement(“link”)
fileref.setAttribute(“rel”, “stylesheet”);
fileref.setAttribute(“type”, “text/css”);
fileref.setAttribute(“href”, file);
}
}
if (fileref!=""){
document.getElementsByTagName(“head”).item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
</script>
</head>
<body>
<div id="menu">
<h2>Kristian Brace</h2><p>
<ul>
<li><a href="about.html">About</a></li>
<li><a href="#">Projects</a></li>
<li><a href="links.html">Links</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
<div id="header">
<h2>Projects</h2><p>
<ul>
<a href="javascript:ajaxpage('mg_mediacom.swf', 'flash');">MediaCom 2</a>
<li><a href="#">MediaCom</a></li>
<li><a href="cottages.html">Short & Suite</a></li>
<li><a href="cottages.html">British Red Cross</a></li>
<li><a href="cottages.html">poplar Farm</a></li>
<li><a href="cottages.html">VTKTM</a></li>
<li><a href="guestbook.html">aniMate</a></li>
<li><a href="contact.html">Hansel & Gretel</a></li>
<li><a href="cottages.html">Foursight</a></li>
<li><a href="cottages.html">Timelapse</a></li>
<li><a href="cottages.html">3D Showreel</a></li>
<li><a href="cottages.html">The Iron Man</a></li>
</ul>
</div>
<div id="content">
<h2>Mediacom</h2><p>
<a href="javascript:ajaxpage('mg_mediacom.swf', 'flash');">MediaCom 3</a>
<div id="flash">
</div>
<p>MediaCom</p>
<p>This is a description of the flash movie playing above.</p>
</div>
<div id=“footer”>
<p id="legal">Copyright © 2009 . All Rights Reserved.</p>
</div>
</body>
</html>
[/COLOR][/SIZE]
When the html button is clicked it loads but displays a mass of nonsense code.
does anybody have any ideas or experience with loading swf from html
Thanks