views:

34

answers:

3

Hi all,

I am using thick box 3.1 to load a pop up. It working well by using in the following way:

<a href="filename.php" class="thickbox"> TEST </a>

If we click on the TEST now then the popup is working well and good.

Now my prob is: I need to call this popup in form load using JavaScript.

I do something like below:

<script type="text/javascript">

window.location.href = "filename.php"    

</script>

it's just redirecting to that particular file. But not showing in the pop up.

What is the possible way?

thanks in advance

+1  A: 

Try this:

<a href="filename.php" class="thickbox" id="openOnLoad">Test</a>

<script type="text/javascript">
$(function(){ // On DOM ready
    $('#openOnLoad').click();
});
</script>
Simeon
thanks simeon, This is what i exactly wan't. Thanks a lot man.
Fero
A: 
<a href="filename.php" class="thickbox" id="UniqueIdForThisLink"> TEST </a>

<script type="text/javascript">
  $("#UniqueIdForThisLink").click();
</script>
Tomalak
thanks for your answer tomalak
Fero
You're missing document.ready ...
James Westgate
@James: Yeah... true. My focus was on using `click()` as the answer to the question, not not on making a standalone fully functional example.
Tomalak
+1  A: 

You can do this without changing your markup, like this:

$(function() {
  $('a[href=filename.php]').click();
});
Nick Craver
thanks for your answer.
Fero