سؤال

This link works perfect:

<a href='#' onclick='window.parent.jQuery.colorbox({href:"test.php"}); return false;'>
    CLICK HERE 
</a>

How do i code this so that when someone goes to my page it will automatically open the window with these settings above?

it should open that link onLoad in the parent window

any ideas?

هل كانت مفيدة؟

المحلول

It's pretty simple:

<body onload='window.parent.jQuery.colorbox({href:"test.php"}); return false;'>

نصائح أخرى

Since you're using jQuery already:

$(document).ready(function() { 
    // do something. 
});

You may want to use .load() instead of .ready(), depending on your needs. Basically the difference is load waits until all the images on the page have loaded, whereas ready doesn't. Here are the docs.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top