【发布时间】:2012-08-20 00:42:27
【问题描述】:
我正在使用 jQuery 的可爱而简单的dialog 命令在一些嵌入的第 3 方内容前面打开一个对话框。该嵌入内容可以是来自任何网站的页面。我可以让它在某些网站(Yahoo、Google)上运行,但我不能让它在其他网站(MSN、Johnlewis、FT)上运行。
我已经从下面的代码中尽可能多地删除了问题的基本内容 - 显示的代码工作正常并且对话框确实显示。但是,注释掉 YAHOO 行,取消注释 MSN 行,对话框就不会显示了!!
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<style>
.ui-widget-header { border: 1px solid #aaaaaa; background: #1f84f5 url(images/ui-bg_highlight-hard_75_1f84f5_1x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; font-size: 20pt; }
.ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; font-size: 20pt;}
</style>
<script>
$(document).ready(function() {
$( "#thedialog" ).dialog( "destroy" );
$( "#thedialog" ).dialog({height:400, width:600, modal: true,
buttons: {Cancel: function() {$( this ).dialog( "close" );}}
});
});
</script>
</head>
<body>
<?php
// WORKING - these pages DO launch a dialog:
$targetlink = 'http://www.yahoo.com';
// $targetlink = 'http://www.bbc.co.uk';
// $targetlink = 'http://www.google.com';
// NOT WORKING - these pages do NOT launch a dialog:
// $targetlink = 'http://www.msn.com';
// $targetlink = 'http://www.johnlewis.com';
// $targetlink = 'http://www.ft.com';
echo file_get_contents($targetlink);
?>
<div id="thedialog" title="Simple dialog box" style="display:none">My girl lollipop</div>
</body>
我唯一能想到的是它一定是某个非工作网站上与我的代码冲突的东西 - 我已经尝试了所有方法来错误捕获问题,但找不到导致它的原因。
谁能帮帮我?
注意事项: - (1) 我知道所示示例不需要 PHP,但更完整的版本 确实(我只是剥离了大部分 PHP 代码以保留这个示例 小的)。 - (2) 我在完整版页面的其他地方使用了 JQuery 所以理想情况下,我想继续使用 JQuery,而不是引入替代框架/方法。
【问题讨论】:
-
我检查了代码,它似乎工作。 - 我需要更多详细信息才能提供帮助
-
我建议你使用 chrome 和 f12,看看你是否在 JS 控制台中出现错误。有关更多详细信息,我在 chrome 中设置了一个关于开发人员工具的 wiki 页面:wiki.mograbi.info/developers-tools-for-web-development - 这篇文章还解释了如何以不同的方法错误捕获 JS。
-
没有打开你的对话框。删除 div 的 "style="display:none;" 部分并将参数 "autoOpen: true" 添加到对话框创建中
-
正确 - 代码原样工作,但正如我所提到的,如果您注释掉“$targetlink = 'yahoo.com';”行并取消注释“// $targetlink = 'msn.com';”行它不会工作
-
而且你不需要在创建之前销毁你的对话框
标签: php jquery jquery-ui dialog modal-dialog