2

我想启动一个 jquery 厚盒onload而不是单击。为此,我使用下面的代码。

<script language="javascript">
    tb_show("HAI","#TB_inline?height=240&amp;width=405&amp;inlineId=hiddenModalContent&amp;modal=true",null);
</script>

实际链接是

<a href="#TB_inline?height=240&amp;width=405&amp;inlineId=hiddenModalContent&
amp;modal=true" class="thickbox">Change Name</a>

当我点击上面的链接..粗框出现..

但在身体装载厚框没有出现..

请帮助解决这个问题..

提前致谢...

问候日元

4

4 回答 4

5

您的代码应该可以工作。也许尝试把它放在对 jQuery 的 document.ready 的调用中,例如

<script language="javascript">
    $(document).ready(function() {
        tb_show("HAI","#TB_inline?height=240&amp;width=405&amp;inlineId=hiddenModalContent&amp;modal=true",null);
    });
</script>
于 2010-01-24T21:10:07.993 回答
3

Uffff!!! Finally I have sorted it out, I think your div content is something like
<div id="hiddenModalContent" style="display:none">My Content</div>
Try this instead of the above one
<div id="hiddenModalContent" style="display:none"><div>My Content</div></div>
This should fix the problem. Please note that you have to encapsulate the content in "hiddenModalContent" by an HTMl element e.g. <div>...</div><p>...</p> etc.

Because in thickbox.js file they have used .children() not .html(). This is the reason why we have to encapsulate the content.

于 2012-07-29T00:02:37.153 回答
1

如果您在页面某处有锚链接,您可以执行以下操作:

<script>
$.ready( function() {
    $("#thickBoxLink").trigger("click");
}
</script>

<html>
<body>
<a href="#TB_inline?height=240&amp;width=405&amp;inlineId=hiddenModalContent&amp;modal=true" id="thickBoxLink" class="thickbox">Change Name</a>
</body>
</html>

这应该模拟点击链接并在页面加载时为您打开厚框。

于 2009-11-26T14:51:10.383 回答
0

这与 Matt Frear 建议的解决方案相同,您可以复制并粘贴以进行测试。我更改了厚盒参数,但您可以根据需要更改它。

<html>
<head>
   <link rel="stylesheet" type="text/css" media="screen" href="http://jquery.com/demo/thickbox/thickbox-code/thickbox.css" />
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script src="http://jquery.com/demo/thickbox/thickbox-code/thickbox-compressed.js" type="text/javascript"></script>

<script type='text/javascript'>
$(document).ready(function() {
   tb_show('HAI','http://microsoft.com?KeepThis=true&TB_iframe=true&height=350&width=520');
});
</script>

</body>
</html>
于 2010-03-02T14:57:15.247 回答