your asking on the wrong forum really this is more of a programming issue not flash! but hey ill I answer you question and maybe the captaions of this ship will move it to the relevant forum.
use the ajax method,.. this calls a server side script using requst object in javascript to load html content without refreshing page.
place this in the head of your html file,....
<script type="text/JavaScript">
function makeObject(){
var x;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
x = new ActiveXObject("Microsoft.XMLHTTP");
}else{
x = new XMLHttpRequest();
}
return x;
}
var request = makeObject();
function getPage(page){
//The function open() is used to open a connection.
//Parameters are 'method' and 'url'. For this tutorial we use GET.
//We send it to 'test.php?id=' and add the index from our SELECT form field
request.open('post', 'getPage.php');
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
//This tells the script to call parseInfo() when the ready state is changed.
request.onreadystatechange = parseInfo;
//This sends whatever we need to send. Unless you're using POST as method, the parameter is to remain empty.
getstr='page='+page;
request.send(getstr);
}
function parseInfo(){
if(request.readyState == 1){
//While we are still waiting for a response, we replace whatever's in the div # 'my_div' with
//the text 'Loading...'.
document.getElementById('my_div').innerHTML = '<img src="assets/loading.gif" />';
}
if(request.readyState == 4){
//request.responseText holds the response we got from the server.
//We assign it to a variable and replace the content of 'my_div' when it's done loading
var answer = request.responseText;
document.getElementById('my_div').innerHTML = answer;
}
}
</script>
- <script type="text/JavaScript">
- function makeObject(){
- var x;
- var browser = navigator.appName;
- if(browser == "Microsoft Internet Explorer"){
- x = new ActiveXObject("Microsoft.XMLHTTP");
- }else{
- x = new XMLHttpRequest();
- }
- return x;
- }
- var request = makeObject();
- function getPage(page){
-
- //The function open() is used to open a connection.
- //Parameters are 'method' and 'url'. For this tutorial we use GET.
- //We send it to 'test.php?id=' and add the index from our SELECT form field
-
-
- request.open('post', 'getPage.php');
-
- request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
- //This tells the script to call parseInfo() when the ready state is changed.
- request.onreadystatechange = parseInfo;
- //This sends whatever we need to send. Unless you're using POST as method, the parameter is to remain empty.
-
- getstr='page='+page;
- request.send(getstr);
- }
- function parseInfo(){
- if(request.readyState == 1){
-
- //While we are still waiting for a response, we replace whatever's in the div # 'my_div' with
- //the text 'Loading...'.
- document.getElementById('my_div').innerHTML = '<img src="assets/loading.gif" />';
- }
- if(request.readyState == 4){
- //request.responseText holds the response we got from the server.
- //We assign it to a variable and replace the content of 'my_div' when it's done loading
- var answer = request.responseText;
- document.getElementById('my_div').innerHTML = answer;
- }
- }
- </script>
you will see baove I have sent a request to get Page.php
If you dont know php copy and paste the below into a new file and call it getPage.php
<?php
$html=file_get_contents($_POST['page']);
echo "html = ".$html;
?>
- <?php
-
- $html=file_get_contents($_POST['page']);
-
- echo "html = ".$html;
-
- ?>
-
this will have to sit in the same directory as your main html file, if you move it you will have to change the path in the request the same as you would any other file.
you will see in the parseInfo function I have sent the response from the php to 'my_div' so create a div element in the body of your html and giv it the id of 'my_div' ( you can call this what u like but make sure to cahnge it in the parseInfo function.
know you can call the getPage function from any button or link etc with the parameter of the name of the html file you wish to load. eg.
<a href="javascript:;" onclick="getPage('page.html')">show Page</a>
I have zipped up example files for you at
http://www.skindc.co.uk/showPage.zip
use these files for know but make sure you look further into ajax processing so youunderstand it further
G[/url]