我通常使用彩盒工具在我的页面中打开“弹出窗口”,一切都很好。在我的新项目中,情况略有不同,因为我使用 js/ajax/dom 在 handleRequestStateChange() 函数中动态地创建我的对象。
在为 colorbox 导入 js、jquery 和 css 之后,在我的 js 页面的头部我写:
$(document).ready(function () {
$(window).scroll(function () {
//oP1 = document.createTextNode(posizione_menu.offsetTop);
//divIpt.appendChild(oMtx1);
$(".divHcss").css("position", "fixed").css("top", "0px").css("z-index", "999");
});
//Examples of how to assign the Colorbox event to elements
$(".group1").colorbox({rel:'group1'});
$(".group2").colorbox({rel:'group2', transition:"fade"});
$(".group3").colorbox({rel:'group3', transition:"none", width:"75%", height:"75%"});
$(".group4").colorbox({rel:'group4', slideshow:true});
$(".ajax").colorbox();
$(".youtube").colorbox({iframe:true, innerWidth:640, innerHeight:390});
$(".vimeo").colorbox({iframe:true, innerWidth:500, innerHeight:409});
$(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
$(".inline").colorbox({inline:true, width:"50%"});
$(".callbacks").colorbox({
onOpen:function(){ alert('onOpen: colorbox is about to open'); },
onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
});
$('.non-retina').colorbox({rel:'group5', transition:'none'})
$('.retina').colorbox({rel:'group5', transition:'none', retinaImage:true, retinaUrl:true});
//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
return false;
});
});
在 handleRequestStateChange() 之后,我创建了一个元素并分配给一个 div:
var a = createElement('a');
//a.style.display = "block";
a.setAttribute('class','iframe');
a.setAttribute('href',"php/whois.php?P1="+oStxt.value);
var divIp3 = createElement('div', 'divIp3', 'divIp3css');
var divIp31 = createElement('div', 'divIp31', 'divIp31css');
divIp3.appendChild(divIp31);
divIp3.appendChild(a);
a.appendChild(divIp31);
divIp31 变得可链接,但 href 在普通浏览器选项卡中打开页面,并且不使用颜色框的属性类。
有人有想法吗?
提前致谢
是