0

I have following scenario: User clicks on a link with parameter like this

www.abc.com/page1?xxx. 

On page1 I would like to have script that detects parameter xxx and runs a link with a class asap (no need to wait for dom to finish, it can be in background)(running a link opens modal window with some text). I use jquery 1.8.

Edit: I am using following code: based on this question Conditionally open popup video based on URL query string

(function($){ 

Drupal.behaviors.zzz = {
  attach: function (context) {

$(document).ready(function(){               


    function getURLParameter(name) {
        return decodeURI(
            (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
        );
    }
    if(getURLParameter('param')==1){
      $(".colorbox-node").trigger('click');
    }
});


}
};
})(jQuery);

However, there seems to be some loop jquery that prevents the page to finish loading. I suppose that is caused by colorbox plugin trying to set top value and looking at the console I can see "setting top" message constantly working until browser crashes. How to avoid this? Thank you

Community
  • 1
  • 1
user1031743
  • 319
  • 1
  • 5
  • 14
  • Yes it is. If you have a *specific* question, feel free to ask. In general, yes/no questions are not a good fit for SO. – Felix Kling Sep 09 '14 at 23:48

1 Answers1

1

This might be a start to your question.

You can get the parameter from document.location.search. If you have multiple parameters, you might need to apply a regular expression to it.

 var loc = document.location.search;

You can then open your new window

 window.open(loc);   

JQuery UI would be helpful in constructing a modal popup.

terrywb
  • 3,740
  • 3
  • 25
  • 50