我有這個腳本,將打開彈出時,單擊任何機構。 如何改變身體點擊它應該是按鈕點擊或鏈接點擊彈出之前出現?我需要創建任何按鈕嗎?代碼非常感謝。更改主體onclick到按鈕onclick
<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/(按扭CREATE請播放。)
我回答這個問題,以供參考:
<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>
你問它是否能夠處理按鈕點擊沒有按鈕? – SLaks
現在,當我點擊任何頁面的彈出窗口將出現..我不想那樣。我想它應該是一個按鈕點擊或鏈接點擊不頁身體點擊 – airi
把'.onclick = function(){}'放在一個按鈕元素而不是body上。 –