My best guess is to do this with a XMLHttpRequest
.
First decide which page you should load. After that, load the page. For example:
var width = window.innerWidth;
var page;
if (width < 321) {
page = 'index320.html';
} else if (width >= 321 && width < 481) {
page = 'index480.html';
} else {
page = 'indexother.html';
}
// http://stackoverflow.com/questions/3038901/how-to-get-the-response-of-xmlhttprequest
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
// do some stuff with the content
alert(xhr.responseText);
}
}
xhr.open('GET', page, true);
xhr.send(null);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…