我在使用jquery load()函数加载谷歌幻灯片(http://www.google.com/uds/solutions/slideshow/index.html)到我的Web应用程序时遇到问题。
的index.html:
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<div id="moshe"></div>
<script type="text/javascript">
$(document).ready(function(){
$('#moshe').load('test.html');
});
</script>
的test.html:
<script type="text/javascript">
function load() {
var samples = "http://dlc0421.googlepages.com/gfss.rss";
var options = {
displayTime: 2000,
transistionTime: 600,
linkTarget : google.feeds.LINK_TARGET_BLANK
};
new GFslideShow(samples, "slideshow", options);
}
google.load("feeds", "1");
google.setOnLoadCallback(load);
</script>
<div id="slideshow" class="gslideshow" style="width:300px;height:300px;position:relative; border: 2px solid blue">Loading...</div>
当我执行test.html时,它加载幻灯片就好了。当我尝试加载使用index.html实际上调用Jquery的$ .load()函数,该函数将test.html的内容加载到特定的div元素中时,我看到该库正在加载该div,但是当它即将显示时图像整个页面清除,我所拥有的只是一个空白页。
有什么想法吗?
不使用jquery的不同版本的index.html:
<script type="text/javascript">
function makeRequest(url) {
var httpRequest;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
if (httpRequest.overrideMimeType) {
httpRequest.overrideMimeType('text/xml');
// See note below about this line
}
}
else if (window.ActiveXObject) { // IE
try {
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
if (!httpRequest) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
httpRequest.open('GET', url, true);
httpRequest.send('');
}
function alertContents(httpRequest) {
if (httpRequest.readyState == 4) {
if (httpRequest.status == 200) {
document.getElementById('moshe').innerHTML=httpRequest.responseText;
} else {
alert('There was a problem with the request.');
}
}
}
makeRequest('test.html');
</script>
答案 0 :(得分:0)
尝试放
$('#moshe').load('test.html');
进入
$(document).ready(function(){
$('#moshe').load('test.html');
});
另外,我不知道你是否复制或输入了这个,但你有
<script style="text/javascript">
何时需要
<script type="text/javascript">
我个人使用:
<script language="javascript">
但我不确定哪个最好。