First of all, I want to tell you that this Module is amazing. It is exactly what I have been looking for.

Now, to the business at hand, I would love to have a popup load when a certain page is visited.
Example: When an anonymous user visits the front page, the login/register node I created pops up.

I don't want to redirect them to the node itself, I want to stay on the front page. Is this possible without a physical "click" on the link?

Comments

cmporter83’s picture

I have been going through everything I can find on this topic to try and make this happen. I have even tried the standard Javascript onLoad click stuff, but sadly it doesn't remember the Class so it loads the page itself, and skips the popup. I have tried going through all of the JS code for the module, but honestly it is over my head. I cant seem to identify anything in there that I can just call out to create a popup.

At this point, I have created a block that only shows when anonymous users hit my front page. I have placed a link within that block that when clicked a popup with a custom login/register screen. I wonder if using some script to create the popup when the ID is present would work.

Example: The block contains the link with an id of "autopop". Then using "document.getElementById('autopop')" to launch the popup.

Anyone wanna help?

cmporter83’s picture

Well i have found a way that this sort of works in IE only.... but things dont work quite right, and dont work in FFox. Anyone out there up for helping?

I made a link with the class="popups" and id="autopop" then added the following to the page-front.tpl.php

  <script type="text/javascript">
function init() {
  document.getElementById('autopop').click();
}

onload=init;
  </script>
rjdjohnston’s picture

Did you figure this out? I have the same need.

cmporter83’s picture

I have been working on this since December, and still don't have an answer. Can ANYONE out there help me? All I am trying to do is launch the login form in a popup when someone loads a page. No click of the link, it just pops up as soon as the page loads. Surely this can't be that complicated!

What is the actual process that happens when a link with that ID is clicked? Can we not just run that operation on load?

beyond67’s picture

Im curious about this also.

Bertjuh’s picture

Wow, still no solution? I'm having the same problem. I've tried for some days now different combinations of modules like popup, webforms, popup block, ajax api but no solution to the automatic popup thing.

BTW document.getElementByID works fine on IE but not on all browsers, there is other code to make sure it works on all browsers.

jacobpov’s picture

please update on this one I need this kind of thing to work.

Michsk’s picture

this is not a nice way, but you could create a hidden link (css) and when the body is loaded make jquery click that link to open the popup.

Michsk’s picture

this is not a nice way, but you could create a hidden link (css) and when the body is loaded make jquery click that link to open the popup.

hrmoller’s picture

Subscribing. Will contribute when/if I got something.

jefkin’s picture

Assuming your link is still provided with id="autopop",

Add this code to your home page, perhaps in a block.

<script type="text/javascript">
/* <![CDATA[ */ 

var autopopup = function ()
{
  sleep(3); // give popups time to load up
  $('#autopop').click();
};

$(document).ready(autopopup);

/* ]]> */
</script>

==========

Alternatively you can make a mini-module to do this, (I prefer the mini-module method, as it's more robust and simpler to repeat).

Mandakini_Kumari’s picture

I tried on http://ayushiinfotech.com/ but not worked for me.
Currently I am using below script

<div style="display: none;" id="light" class="white_content"> include("index1.html");</div>
<div style="display: none;" id="fade" class="black_overlay"></div>

function autopopup() { document.getElementById('light').style.display='block'; document.getElementById('fade').style.display='block'; } autopopup();
YK85’s picture

subscribing

ruinze’s picture

if you're creating a module you can add a JS and use Drupal.behaviors and put some event that if an id of a certain element is present then display it on popup

example :
on your page

<div id="my_id" style="display:none;">

	Welcome,
        This div should be hidden and let popups display it

</div>

    

on your js

Drupal.behaviors.checkId = function(context){
	
	$("#my_id:not(.processed)",context).each(function(){
		$(this).addClass("processed");
		Popups.message("Title", $("#my_id").html());
	});
	
};

i'm sure we can implement this when not on module
sorry for my bad english

Ramandeep_Kaur’s picture

Thanks ruinze , this solution works like a charm.
We need to keep 2 things in mind for this code to work
1) The popups module is enabled.
2) In the popups configuration page "Scan all pages for popup links." is checked.

tacoparty’s picture

Could someone post some basic directions on how to do this? I see chunks of advice here but am not really sure where to start. All I need, like the original poster, is for a pop-up to display when a certain page loads. I'm surprised this isn't more common or easier to do with Drupal. I've been looking all over to no avail.

hawkeye.twolf’s picture

@tacoparty - Here are the steps to make this work:

  1. Add @ruinze's php code (repeated below) either into a template file or into the body of a node (using PHP input format).
     drupal_add_js( "Drupal.behaviors.checkId = function(context){
    	$('#my_id:not(.processed)',context).each(function(){
    		$(this).addClass('processed');
    		Popups.message('IP Tracks Disclaimer', $('#my_id').html());
    	});
    };", "inline" ); 
  2. Create a div and set it's id="my_id" (or change "my_id" in the code above; note it must be changed in two places). Also set the div's style="display:none;"
  3. As @raman2385 mentioned, enable the Popups module and set it's configuration page to "Scan all pages for popup links."

Hope that helps!

diwakar’s picture

hi derek.deraps,
thank you for explaining it,now that i got the popups with a message, if you could pl guide as to how to include login form,
thank you