0
我正在使用多个视图运行健康和监视仪表板,并且想要定期显示所有视图作为幻灯片放映。在ASP.NET MVC中显示不同视图作为幻灯片显示
<iframe src="http://jquery.com/" id="myFrame" width="500" marginwidth="0" height="500" marginheight="0" align="middle" scrolling="auto"></iframe>
<script>
setInterval(test, 10000);
function test(){
//setTimeout(loadPage1, 2000);
setTimeout(loadPage2, 2000);
setTimeout(loadPage3, 2000);
}
function loadPage1(){
var loc = "http://www.w3schools.com/";
document.getElementById('myFrame').setAttribute('src', loc);
}
function loadPage2(){
var loc = "https://internalapplication/Controller/ActionName1";
document.getElementById('myFrame').setAttribute('src', loc);
}
function loadPage3(){
var loc = "https://internalapplication/Controller/ActionName2";
document.getElementById('myFrame').setAttribute('src', loc);
}
</script>
http://jsfiddle.net/35s3m6ru/2/
我得到下面的错误。
“拒绝在框架中显示'https://internalapplication/Controller/ActionName1',因为它将'X-Frame-Options'设置为'SAMEORIGIN'”。
任何帮助或建议将不胜感激。
编辑:相对URL
http://jsfiddle.net/35s3m6ru/6/
使用相对URL和'controller/actioname'而不是viewname – Shyju
谢谢Shyju。我已经用相关的URL http://jsfiddle.net/35s3m6ru/6/更新了代码。请参阅索引页面加载正常,但iframe内容不会使用NotificationSummary/ErrorSummary内容进行刷新。我的目标是显示“索引”视图20秒,NotificationSummary和ErrorSummary每个10秒,然后无限重复整个过程。 – redsam
我想你会更好地使用部分视图和Ajax调用来加载它们比iframe。 – SvenAelterman