Показать сообщение отдельно
  #6 (permalink)  
Старый 20.09.2012, 15:59
Аватар для lord2kim
Профессор
Отправить личное сообщение для lord2kim Посмотреть профиль Найти все сообщения от lord2kim
 
Регистрация: 03.05.2011
Сообщений: 848

fantasy_h1,
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; Charset=UTF-8">
<script>
function showContent(link) {

var cont = document.getElementById('contentBody');
var loading = document.getElementById('loading');

cont.innerHTML = loading.innerHTML;

var http = createRequestObject();
if( http ) {
http.open('get', link);	
http.onreadystatechange = function () {
if(http.readyState == 4) {
cont.innerHTML = http.responseText;
}
}
http.send(null);    
} else {
document.location = link;
}
}

function createRequestObject() {
try { return new XMLHttpRequest() }
catch(e) {
try { return new ActiveXObject('Msxml2.XMLHTTP') }
catch(e) {
try { return new ActiveXObject('Microsoft.XMLHTTP') }
catch(e) { return null; }
}
}
}

function selChange( self ) {
    var links = ['',
      '/xxxx.html',
      'zzzz.html'
    ];
    if ( links[ self.value ] ) {
        showContent( links[ self.value ] );
    }
}
</script>
</head>

<body>

<p>Вопрос?</p>

<select onchange="selChange( this )">
    <option value="0"> - выберите вариант - </option>
    <option value="1">вариант 1</option>
    <option value="2">вариант 2</option>
</select>

<div id="contentBody">
</div>

<div id="loading" style="display: none">
Идет загрузка...
</div>

</body>
</html>
Ответить с цитированием