As you know you cannot use alert function inside popup's
I writed a small "alert" function to use inside browserAction popup:

Example Use:
--------------------
Without callback:
alert('Shalom Lachem This is test\nWorking Great!');

With callback:
alert('Shalom Lachem This is test\nWorking Great!',function () {alert
('working')});

the callback function called when the user click on 'OK'.

The function:
------------------
function alert(message,callback){
window.d=document.createElement('div');
d.style.position='absolute';
d.id='alert';
d.style.minWidth='50px'
d.style.maxWidth='450px'
d.innerHTML='<div style="white-space:nowrap;border:2px solid
#00d;background-color:#ddd;"><div style=color:white;padding:
3px;background-color:#00d;>Alert ' + document.location + '</div><div
style=padding:5px;>' + message.replace(/\n/,'<br>') +'</div>' + '<div
align=right><button id=alert_ok
onclick="javascript:document.body.removeChild(document.getElementById
(\'alert\'))">OK</button></div></div>';
document.body.appendChild(d);
if(callback) document.getElementById('alert_ok').addEventListener
('click',callback);
d.style.top='0px'
d.style.top=document.body.scrollTop+
(document.documentElement.clientHeight/2-d.offsetHeight/2) + 'px';
d.style.left=(document.body.scrollLeft+
(document.documentElement.clientWidth/2-d.offsetWidth/2)) + 'px';
}
-- 
You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to chromium-extensi...@googlegroups.com.
To unsubscribe from this group, send email to 
chromium-extensions+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en.


Reply via email to