i have this script that will open popup when click any body. how to change instead body click it should be button click or link click before the popup appear? Do i need to create button of anything. code much appreciate.
<script type="text/javascript">
var win = window.open('http://google.com', "popup", 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=650, left = 300, top = 50');
if (!win){
// alert("failed for most browsers");
document.body.onclick = function () {
window.open('http://google.com', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=650, left = 300, top = 50');
};
}else {
var thisdoc = document;
//Is it Chrome?
if(/chrome/.test(navigator.userAgent.toLowerCase())){
setTimeout(function() {
if ((win.innerHeight > 0) == false){
// alert("failed for chrome");
thisdoc.body.onclick = function () {
window.open('http://google.com', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=650, left = 300, top = 50');
};
}
}, 100);
}else{
win.onload = function() {
if ((win.innerHeight > 0) == false){
// alert("failed for others");
thisdoc.body.onclick = function () {
window.open('http://google.com', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=650, left = 300, top = 50');
};
}
};
}
}
</script>
JS : FIDDLE : http://jsfiddle.net/ayiem999/678Ru/ ( WITH BUTTON CREATE. PLEASE PLAY)
MY ANSWER FOR THIS QUESTION FOR REFERENCE :
<button id="3" onclick="reply_click(this.id)">B3</button>
<script type="text/javascript">
function reply_click(clicked_id)
{
window.open('http://google.com', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=650, left = 300, top = 50');
}
</script>