/    Sign up×
Community /Pin to ProfileBookmark

Popunder code stays on top

I got this code from javascript.internet.com almost as is. The areas I modified myself are bold. I added a url. then close to the bottom I added two lines that should have blured the new window and then moved the original window back to focus. The new windows pops us and stays on top…it doesn’t go under….Can anyone help?….Thanks in advace.

<SCRIPT LANGUAGE=”JavaScript”>

<!– This script and many more are available free online at –>
<!– The JavaScript Source!! [url]http://javascript.internet.com[/url] –>

<!– Begin
var expDays = 1; // number of days the cookie should last

var page = “[B][url]http://www.osimarketing.com[/url][/B]“;

var windowprops = “width=300,height=200,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes”;

function GetCookie (name) {

var arg = name + “=”;

var alen = arg.length;

var clen = document.cookie.length;

var i = 0;

while (i < clen) {

var j = i + alen;

if (document.cookie.substring(i, j) == arg)

return getCookieVal (j);

i = document.cookie.indexOf(” “, i) + 1;

if (i == 0) break;

}

return null;
}
function SetCookie (name, value) {

var argv = SetCookie.arguments;

var argc = SetCookie.arguments.length;

var expires = (argc > 2) ? argv[2] : null;

var path = (argc > 3) ? argv[3] : null;

var domain = (argc > 4) ? argv[4] : null;

var secure = (argc > 5) ? argv[5] : false;

document.cookie = name + “=” + escape (value) +
((expires == null) ? “” : (“; expires=” + expires.toGMTString())) +
((path == null) ? “” : (“; path=” + path)) +

((domain == null) ? “” : (“; domain=” + domain)) +

((secure == true) ? “; secure” : “”);
}
function DeleteCookie (name) {

var exp = new Date();

exp.setTime (exp.getTime() – 1);

var cval = GetCookie (name);

document.cookie = name + “=” + cval + “; expires=” + exp.toGMTString();
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie(‘count’)
if(count == null) {
SetCookie(‘count’,’1′)
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie(‘count’)
SetCookie(‘count’,newcount,exp)
return count
}
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (“;”, offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
var count = GetCookie(‘count’);
if (count == null) {
count=1;
SetCookie(‘count’, count, exp);

window.open(page, “”, windowprops);
[B]page.blur();
window.focus();[/B]

}
else {
count++;
SetCookie(‘count’, count, exp);
}
}
// End –>
</script>

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@dthurman1432Jun 20.2006 — take out the:

page.blur();

window.focus();

This basically is saying when you click away refocus on the window which is the popup
Copy linkTweet thisAlerts:
@oseymourauthorJun 20.2006 — That's the code I thought would do the trick........How do i get the new window to lose focus and move to the background
Copy linkTweet thisAlerts:
@dthurman1432Jun 20.2006 — Do you want the popup to lose focus immediately when it comes up (like some advertisement popups) or just the ability for the user to keep it open and click back to the opener page?
Copy linkTweet thisAlerts:
@oseymourauthorJun 21.2006 — I want the popunder to lose focus immediately when it comes up...Just like the ads
Copy linkTweet thisAlerts:
@dthurman1432Jun 21.2006 — Try adding this to the body tag of the opener page:

[COLOR=Navy]onBlur="self.focus()"[/COLOR]

Or add the below into a javascript tag in your header

[COLOR=Navy]window.onblur = function() {

focus.self();

}[/COLOR]


Not sure which one is going to work for you.
×

Success!

Help @oseymour spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...