我希望能够打开一个新窗口/选项卡后,把重点放在原来的页面,以同样的方式,因为它是这个网站上完成:http://www.vouchercodes.co.uk/laredoute.co.uk如何在打开新窗口后关注主页面?
1
A
回答
0
它,当你点击绿色按钮“获取代码和开放的网站” 。
代码全部在这里供您查看。我使用了萤火虫查找将点击事件绑定到代码的<a>
对象,该代码在主浏览器窗口后面弹出。我向下滚动查看global.js文件,发现这个:
基本上.blur()
在指定的弹出窗口将通过焦点返回到支持它的浏览器的主窗口和return false;
将确保链接不会打开在当前窗口中是默认行为。向下滚动下面的代码,你会看到底部。
// -- VoucherClick --
// This baby does the funky stuff when the user clicks to reveal the voucher code
(function($) {
$.fn.extend({
voucherClick: function(config) {
return this.each(function() {
// What is the objects parent?
var theObject = $(this);
if ($(this).hasClass('the-image')) {
var theParent = theObject.parent().parent();
} else {
var theParent = theObject.parent().parent().parent();
}
theObject.click(function() {
// Revealed codes have a light yellow background
// First we remove the background of any currently selected vouchers
$('.selected-voucher').css('backgroundColor','#fff').removeClass('selected-voucher');
// Now we add the yellow background. We have to check what was clicked as it affects
// how far up the DOM tree the voucher DIV starts
// We also must check if we are on an indiviual page with an expired voucher,
// because the yellow background can overlap the left hand edge of the voucher
if (theParent.parent().hasClass('individual-expired')) {
} else {
theParent.css('backgroundColor','#ffffee').addClass('selected-voucher');
}
// Check to see if the voucher has alread been revealed - we only want to run this
// if it hasn't yet been clicked
if (!theParent.data('voucherRevealed')) {
// Make a note that this voucher has been clicked
theParent.data('voucherRevealed', true)
// Make a note of the voucher code and create the revealed code module
var thisCode = theParent.find('strong').html();
// If the code is over 18 characters, we need to reduce the font size
if (thisCode.length > 8) {
thisCode = '<span class="revealedVoucherCode small">' + thisCode + '</span>';
} else {
thisCode = '<span class="revealedVoucherCode">' + thisCode + '</span>';
}
// Fade out the initial module and fade in the revealed voucher module
theParent.find('.code-wrapper').fadeOut('normal', function() {
// If it's an individual page there is no H3
if (theParent.find('h3').length == 0){
// So we add the revealed module after the dates
theParent.find('.dates').after('<div class="revealedVoucher">' + thisCode + '</div>');
} else {
theParent.find('h3').after('<div class="revealedVoucher">' + thisCode + '</div>');
}
theParent.find('.revealedVoucher').fadeIn();
})
}
// Open the merchant link in a new window
var mer_window = window.open(theObject.attr('href'), '_blank', 'toolbar=1,location=1,directories=1,scrollbars=1,resizable=1,status=1,menubar=1');
// Where browsers support it, let's pop this new window BEHIND the current window
if (typeof mer_window === "object") {
mer_window.blur();
}
// Reveal the What Just Happened Text, which was set up in the VoucherInit function
theParent.find('.what-just-happened').slideDown();
// Don't open the link in this current window
return false;
}); // end theObject click function
}) // end this.each function
} // end function(config)
}) // end $.fn.extend
}) (jQuery);
0
根据上面的例子中,我已经把下面的代码,但点击时无法正常工作......
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script type="text/javascript">
(function($) {
$.fn.extend({
myClick: function(config) {
return this.each(function() {
var theObject = $(this);
theObject.click(function() {
var new_window = window.open(theObject.attr('href'), '_blank', 'toolbar=1,location=1,directories=1,scrollbars=1,resizable=1,status=1,menubar=1');
if (typeof new_window === "object") {
new_window.blur();
}
return false;
});
})
}
})
}) (jQuery);
$('.fade').myClick();
</script>
</head>
<body>
<a href="http://www.google.com" class="fade" target="_blank">Google</a><br />
</body>
</html>
相关问题
- 1. 关闭从主页面打开的新窗口后,页面正在刷新
- 2. 如何在<form>打开新窗口后刷新主页?
- 3. 在新窗口中打开页面
- 4. 在新窗口中打开asp.net页面
- 5. HTML:在新窗口中打开页面
- 6. 打开新窗口,不关注它
- 7. 刷新页面并打开新窗口
- 8. 如何在新标签页/窗口中打开ASP页面?
- 9. 打开一个新窗口并在5秒后关闭窗口
- 10. 如何在页面关闭时打开调查窗口?
- 11. Telerik窗口在每次页面刷新后自动打开
- 12. Javascript页面在打开新窗口后停止响应
- 13. 打开新窗口后强制按钮重新加载页面
- 14. 如何在javafx的相同窗口中打开新页面
- 15. 如何防止在新窗口中打开iframed页面
- 16. 如何在同一页面打开一个新窗口
- 17. 如何使用javascript在新窗口中打开页面
- 18. 如何在新窗口中打开页面并发送数据?
- 19. 如何在新窗口中打开PHP /表单结果页面?
- 20. 如何在新窗口中打开当前页面
- 21. 如何创建关闭主窗口时打开的窗口?
- 22. 如何打开弹出窗口并刷新弹出窗口关闭时打开的页面?
- 23. 如何在y关闭第一个窗口后打开一个新窗口?
- 24. 弹出窗口在我关闭并刷新页面后继续打开?
- 25. 如何从Qt的主窗口打开一个新窗口?
- 26. 如何在jQUERY关闭弹出窗口后刷新父页面?
- 27. 如何打开新窗口
- 28. 关闭模式窗口后刷新主页面
- 29. 在主窗口中打开新的UserControl
- 30. 无需在新窗口中打开页面或使用JavaScript在新窗口中打开网页html元素值
你可能会有点不仅仅是更具体的“像这样现场”。我们应该怎样做才能重现您之后的效果? – Patrick 2010-10-03 11:20:45
当您点击一个名为“Get Code&Open Site”的大绿色按钮时,Web浏览器会在后台打开一个新窗口 - 这就是我所追求的,简而言之。 – Ian 2010-10-03 11:27:04