Hi

I found this piece of code:

<script language="javascript" type="text/javascript">
$(document).ready(function(){

window.open("http://www.example.com/");
});


</script>

that I placed in a block and set to only show on my front page and it works kind of. I want to know how I can display a node or the content of a node in a shadowbox when my front page loads for the first time and not load again until they visit the site again.

Is this possible with shadowbox?

Comments

nicholas.alipaz’s picture

You will need to set a cookie in the user's browser using javascript. This isn't something that we will add to the module I am sure. I give you two references:

http://www.w3schools.com/JS/js_cookies.asp - Setting cookies with js
http://plugins.jquery.com/project/cookie - Setting cookies with jQuery if you feel the need to be a little more graceful with your code.

This solution would not necessarily track when their last visit was but do a simple cookie expiration based on a time period. This issue probably has a number of solutions, but a simple expirable cookie would likely be the easiest.

--
Los Angeles Web Design and development for Drupal.

wind_kind’s picture

thanks I'll have look at the links.

tmckeown’s picture

When ever I call shadowbox.open in some js tags I get the following javascript error: container is undefined. Any ideas on how to do this properly with shadowbox module that will not generate an error?

nicholas.alipaz’s picture

tmckeown, this is completely unrelated to this issue. Please open a new support request.

manfer’s picture

Status: Active » Closed (won't fix)
<script language="javascript" type="text/javascript">
window.onload = function(){
  Shadowbox.open({
    content: "http://google.com",
    player: "iframe",
    width: 640,
    height: 480,
  });
};
</script>

That is an example on how to open a page in shadowbox programmatically on load. Notice we have to wait to onload event as on DOM ready -$(document).ready- it won't work (not sure but probably because on DOM ready the initialization of shadowbox is done so we have to wait for that).

All the rest is not something related to shadowbox. That's something to do somewhere out of the scope of shadowbox. To check for the first visit probably can be done just with session.