Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
160
rated 0 times [  167] [ 7]  / answers: 1 / hits: 24703  / 7 Years ago, sun, march 5, 2017, 12:00:00

I was trying to create an auto popup when I access a web store that is developed in Shopif



<SCRIPT TYPE=text/javascript>
function popup(mylink, windowname) {
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string') href=mylink;
else href=mylink.href;
window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
return false;
}
</SCRIPT>

<BODY onLoad=popup('autopopup.html', 'ad')>


I have the above code for Popup Windows Opening Automatically. However, I need assistance on how to make this work on and this is the website that I am trying to work it on https://petit-tapis.co.uk



Thank you in Advance


More From » jquery

 Answers
42

As @Scopey said, modern browsers prevent this behavior from auto occurring. You can however add a click or if you want people to take action first before doing anything else, you can for example add an overlay that blocks any other functionality (but I can tell you that this kills user experience).



Maybe say more what your goal is. Why do you want this extra window to open? What benefit is there in doing this (what do you and what does the user get out of it)?



edit: See my comment below. I also slapped together a very simple version of what I am talking about: https://jsfiddle.net/uthhvu8d/



HTML:



<div class=wrapper>
<div class=overlay>
<form action=>
<input type=text>
<input type=text>
<button>Submit</button>
</form>
</div>
<div class=content>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Maxime, inventore esse aliquam nostrum? Cupiditate provident, delectus, minus voluptatum natus fugiat.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minus temporibus vitae quibusdam maxime natus fugiat quis amet sed perferendis quod.</p>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laboriosam nostrum consequatur animi quod rem eos nihil obcaecati repellat. At, accusamus.</p>
</div>


CSS:



.wrapper {
position: relative;
}

.overlay {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
color: #fff;
display: none;
}


JS:



function showOverlay() {
$('.overlay').show()
}
setTimeout(showOverlay, 2000)

[#58672] Thursday, March 2, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dequant

Total Points: 88
Total Questions: 99
Total Answers: 95

Location: Ukraine
Member since Sun, Dec 13, 2020
4 Years ago
dequant questions
;