gpt4 book ai didi

jquery - 如何根据 Colorbox 本身加载的内容设置 Colorbox 标题?

转载 作者:行者123 更新时间:2023-12-01 01:02:42 24 4
gpt4 key购买 nike

让我解释一下。我使用 Colorbox 加载 HTML 文件并将其显示在 iframe 中。 HTML 文件包含 <title>标签。是否可以使用<title>标签作为 Colorbox 弹出窗口的标题?我可以使用 onComplete事件,但是如何发生?

编辑:我应该澄清代码:

父 HTML:

<!doctype html>
<html>
<head>
<title>This is parent</title>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('a.cb').colorbox({
iframe : true,
title : function() { /* here goes the code */ },
});
});
</script>
</head>
<body>
<a class="cb" href="popup.html">Popup</a>
</body>
</html>

子 HTML:

<!doctype html>
<html>
<head>
<title>The title</title>
</head>
<body>
...
</body>
</html>

基本上我希望 Colorbox 显示子 HTML 代码的标题。

最佳答案

根据文档的不同,这可能是不可能的。如果 iframed 文档与您的父文档位于同一域中,您应该能够执行以下操作:

$(document).ready(function(){
$('a.cb').colorbox({
iframe : true,
fastIframe: false,
onComplete: function(){
var title = $('.cboxIframe')[0].contentWindow.document.title;
$('#cboxTitle').text(title);
}
});
});

关于jquery - 如何根据 Colorbox 本身加载的内容设置 Colorbox 标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11222866/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com