Php 确保页面总是在iframe中加载
我正在我的网站的iframe中使用第三方预订系统。 当用户进行预订时,他们会收到一封带有确认链接的电子邮件,该链接直接指向预订页面(我通常在iframe中显示)。因此,用户只能看到日历,而不是iframe中包含日历的整个页面Php 确保页面总是在iframe中加载,php,jquery,html,iframe,Php,Jquery,Html,Iframe,我正在我的网站的iframe中使用第三方预订系统。 当用户进行预订时,他们会收到一封带有确认链接的电子邮件,该链接直接指向预订页面(我通常在iframe中显示)。因此,用户只能看到日历,而不是iframe中包含日历的整个页面 有没有办法检查页面是否加载到iframe中,如果没有,请在其周围加载一个父页面?在javascript*窗口中。top*需要与窗口类似,但在iframe窗口中不等于window.top <script>if( window.top != window ) win
有没有办法检查页面是否加载到iframe中,如果没有,请在其周围加载一个父页面?在javascript*窗口中。top*需要与窗口类似,但在iframe窗口中不等于window.top
<script>if( window.top != window ) window.top.location = 'PARENT_URL';</script>
if(window.top!=window)window.top.location='PARENT_URL';
希望你能明白这一点:
iframe page.html
<script>
if ( window.top == window.self ) {
location.replace('site.html?path=' + encodeURIComponent(location.href));
}
</script>
<iframe id="iframe"></iframe>
<script>
// site.html?path=lol.html -> lol.html
var path = location.href.split('?').pop().split('path=').pop().split('&').shift(),
iframe = document.getElementById('iframe');
if ( path ) {
iframe.setAttibute('src', decodeURIComponent(path));
}
</script>
if(window.top==window.self){
location.replace('site.html?path='+encodeURIComponent(location.href));
}
site.html
<script>
if ( window.top == window.self ) {
location.replace('site.html?path=' + encodeURIComponent(location.href));
}
</script>
<iframe id="iframe"></iframe>
<script>
// site.html?path=lol.html -> lol.html
var path = location.href.split('?').pop().split('path=').pop().split('&').shift(),
iframe = document.getElementById('iframe');
if ( path ) {
iframe.setAttibute('src', decodeURIComponent(path));
}
</script>
//site.html?path=lol.html->lol.html
var path=location.href.split('?').pop().split('path=').pop().split('&').shift(),
iframe=document.getElementById('iframe');
如果(路径){
iframe.setAttibute('src',decodeURIComponent(path));
}
但您可能会遇到有关iFrame的问题。。。。brrrr。。。他们都90多岁了:P你要求的是可以完成的,但你需要按顺序完成。我知道,我也讨厌iFrame,但我们必须包括这个日历,它似乎是唯一的选择@空:请在回答中建议序列,我会试试。这看起来不错,我会试试&让你知道。