I am using the following AS to load html data into a <div id="content></content>
on (release, releaseOutside) {
fscommand("loadPage", "about.html");
}
I also want to load additional content into the same DIV from conventional HREF links. Do I use a variation of the above?
<script type="text/javascript">
// You can put in some stuff to show while it loads the page
var loadingmessage = "Loading page... Please wait";
var xmlHttp;
function createRequest(){
if(window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
else if(window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); }
}
function loadPage(pageurl){
// It puts the <div> in a variable here, so it can write to the tag.
var content = document.getElementById("content");
// Here the variable loadingmessage is put in, so it will be shown until the page is downloaded.
content.innerHTML = loadingmessage
createRequest();
var url = pageurl;
xmlHttp.open("GET", url, true);
// Here you tell it to run this function when it has fetched the content - pretty much like a flash listener
xmlHttp.onreadystatechange = pageLoaded;
xmlHttp.send(null);
}
function pageLoaded() {
var content = document.getElementById("content");
if(xmlHttp.readyState == 4) {
// Dont ask me about the readyStates, but this works (Read the tutorial i posted)
// The content is here written to the <div>, replacing the loadingmessage variable - voila!
content.innerHTML = xmlHttp.responseText;
}
}
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
function flashmenu_DoFSCommand(command, args) {
if (command == "loadPage") {
loadPage(args);
}
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
<!--
// Catch the fscommand in ie with vbscript, and pass
// it on to JavaScript.
Sub flashmenu_FSCommand(ByVal command, ByVal args)
call flashmenu_DoFSCommand(command, args)
end sub
//-->
</SCRIPT>