[jQuery][error][resolved] GB_CURRENT is null | popup when called from other than onclick didn’t close the popup.

23 Nov

While using Popup jquery plugin, i need to show the popup on text selection instead of that conventional onclick of a link as

getSelected = function() {
var t = '';
if (window.getSelection) {
t = window.getSelection();
} else if (document.getSelection) {
t = document.getSelection();
} else if (document.selection) {
t = document.selection.createRange().text;
return t;
mouseup = function() {
var st = getSelected();
if (st != '')
GB_showCenter('Show popup',url,480,720);


The issue was when the popup is there in result of onclick of a link, it functions well but when it get called on text selection then its fine except the close function, it gives “GB_CURRENT is null” error and didn’t close the popup window.
I tried multiple ways and the most appropriate was to hide the link and to trigger onclick of the link automatically like

jQuery("div-a").prepend("<div style='display:none'>
<a id='popup' href='{url}' 
onclick=\"return GB_showCenter('Popup', this.href,480,720)\"
;>show popup</a></div>");

Even this didn’t work.
Finally i hide the close link of greybox and added custom close link instead as

<img src="{basepath}/greybox/w_close.gif">
<a style="text-decoration:none;color:grey" 
href={url} onclick="top.window.location=this.href;">Close

and it closes the popup 🙂

Leave a comment

Posted by on November 23, 2011 in javascript


Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: