views:

1594

answers:

3

I want to launch a jquery thickbox onload instead of click. for this I use the code below.

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

Actual link is

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

When I click the above link..thick box appears..

but on body onload thick box is not appearing..

Please help regarding this..

Thanks in advance...

regards Yen

A: 

If you have your anchor link somewhere on the page, you can do something like:

<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>

That should simulate clicking on the link and open up the thickbox for you when the page is loaded.

Willson Haw
+1  A: 

Your code should work. Maybe try putting it in a call to jQuery's document.ready e.g.

<script language="javascript">
    $(document).ready(function() {
        tb_show("HAI","#TB_inline?height=240&amp;width=405&amp;inlineId=hiddenModalContent&amp;modal=true",null);
    });
</script>
Matt Frear
A: 

This is the same solution that Matt Frear suggested that you can copy and paste to test. I changed the thickbox parameters but you can change it as you want.

<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&amp;TB_iframe=true&amp;height=350&amp;width=520');
});
</script>

</body>
</html>
João Guilherme