-
-
Save hpbuniat/1021924 to your computer and use it in GitHub Desktop.
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta content="Hans-Peter Buniat" name="author"> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title>Form-Submit Popunder</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
</head> | |
<body> | |
<form id="testSubmit" action="http://www.google.com"> | |
<input type="submit" /> | |
</form> | |
<script type="text/javascript"> | |
/* use jQuery as container for more convenience */ | |
(function($) { | |
/** | |
* Create a popunder | |
* | |
* @param sUrl Url to open as popunder | |
* | |
* @return jQuery | |
*/ | |
$.popunder = function(sUrl) { | |
var bSimple = $.browser.msie, | |
run = function() { | |
$.popunderHelper.open(sUrl, bSimple); | |
}; | |
(bSimple) ? run() : window.setTimeout(run, 1); | |
return $; | |
}; | |
/* several helper functions */ | |
$.popunderHelper = { | |
/** | |
* Helper to create a (optionally) random value with prefix | |
* | |
* @param string name | |
* @param boolean rand | |
* | |
* @return string | |
*/ | |
rand: function(name, rand) { | |
var p = (name) ? name : 'pu_'; | |
return p + (rand === false ? '' : Math.floor(89999999*Math.random()+10000000)); | |
}, | |
/** | |
* Open the popunder | |
* | |
* @param string sUrl The URL to open | |
* @param boolean bSimple Use the simple popunder | |
* | |
* @return boolean | |
*/ | |
open: function(sUrl, bSimple) { | |
var _parent = self, | |
sToolbar = (!$.browser.webkit && (!$.browser.mozilla || parseInt($.browser.version, 10) < 12)) ? 'yes' : 'no', | |
sOptions, | |
popunder; | |
if (top != self) { | |
try { | |
if (top.document.location.toString()) { | |
_parent = top; | |
} | |
} | |
catch(err) { } | |
} | |
/* popunder options */ | |
sOptions = 'toolbar=' + sToolbar + ',scrollbars=yes,location=yes,statusbar=yes,menubar=no,resizable=1,width=' + (screen.availWidth - 10).toString(); | |
sOptions += ',height=' + (screen.availHeight - 122).toString() + ',screenX=0,screenY=0,left=0,top=0'; | |
/* create pop-up from parent context */ | |
popunder = _parent.window.open(sUrl, $.popunderHelper.rand(), sOptions); | |
if (popunder) { | |
popunder.blur(); | |
if (bSimple) { | |
/* classic popunder, used for ie*/ | |
window.focus(); | |
try { opener.window.focus(); } | |
catch (err) { } | |
} | |
else { | |
/* popunder for e.g. ff4+, chrome */ | |
popunder.init = function(e) { | |
with (e) { | |
(function() { | |
if (typeof window.mozPaintCount != 'undefined' || typeof navigator.webkitGetUserMedia === "function") { | |
var x = window.open('about:blank'); | |
x.close(); | |
} | |
try { opener.window.focus(); } | |
catch (err) { } | |
})(); | |
} | |
}; | |
popunder.params = { | |
url: sUrl | |
}; | |
popunder.init(popunder); | |
} | |
} | |
return true; | |
} | |
}; | |
})(jQuery); | |
$('#testSubmit').submit(function() { | |
jQuery.popunder('http://www.fluege.de').popunder('http://www.flug24.de'); | |
}); | |
</script> | |
</body> | |
</html> |
That's fraud, but if is about cookie you can use an iframe on the actual page and is easier.
Anyway, do a timeout that close the window. The main problem is that you can't open the window without a user click action (iframe has no problem about that).
Also, if you want to do that randomize the window size and the seconds before close, if everyone from your website has the same window size or stay for the same time it will seems strange.
That's fraud, but if is about cookie you can use an iframe on the actual page and is easier.
Anyway, do a timeout that close the window. The main problem is that you can't open the window without a user click action (iframe has no problem about that).
Also, if you want to do that randomize the window size and the seconds before close, if everyone from your website has the same window size or stay for the same time it will seems strange.
Great script thank you it helped me a lot :)
Thanks @shapeshifta78 for the chrome21 compatibly-patch
Thanks so much, I panicked when I saw that the pop under script wasn't working any longer on the new Chrome update, but you've pwnt it again! Great Job!
The reason that it stopped working on the new Chrome was that it no longer had variable for
window.mozPaintCount
So now they have
navigator.webkitGetUserMedia
?
Great work. But it displays as Popup instead of Pop-under in Firefox 15.0 on Mac OS. Any fixes?
I love the script, works perfectly on its own, but when trying to integrate it to my script nothing happens.
This is my script:
Password:
<TMPL_IF rar_nfo>
<TMPL_IF image_url>
</TMPL_IF>
<TMPL_IF video_code>
<TMPL_IF msg>
<TMPL_UNLESS no_link>
<TMPL_IF pass_required>
<TMPL_VAR lang_password>:
</TMPL_IF>
<TMPL_IF captcha_on>
: | |
<TMPL_IF countdown>
<TMPL_VAR lang_wait> <TMPL_VAR countdown> <TMPL_VAR lang_seconds>
</TMPL_IF>
<TMPL_IF direct_links>
<TMPL_ELSE>
</TMPL_IF>
</TMPL_UNLESS>
<textarea id="ic0-" style="width:98%;" cols=24 rows=3 onFocus="copy(this);"></textarea>
<TMPL_IF thumb_url>
<textarea id="ic1-" style="width:98%;" cols=24 rows=3 onFocus="copy(this);">[URL=][IMG][/IMG][/URL]</textarea>
<textarea id="ic1-" style="width:98%;" cols=24 rows=3 onFocus="copy(this);">[URL=] - [/URL]</textarea>
<textarea id="ic2-" style="width:98%;" wrap=hard cols=24 rows=3 onFocus="copy(this);"> - </textarea>
<textarea id="ic4-" style="width:98%;" cols=24 rows=3 onFocus="copy(this);"><IFRAME SRC="/embed--x.html" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH= HEIGHT=></IFRAME></textarea>
2<textarea id="ic5-" style="width:98%;" cols=24 rows=3 onFocus="copy(this);"> </textarea>
<textarea id="ic4-" style="width:98%;" cols=24 rows=3 onFocus="copy(this);">
</textarea>
|
<TMPL_IF enable_file_comments>
<TMPL_INCLUDE comments.html>
<TMPL_IF more_files>
What i am trying to do is when a user click the "Request Download or Streaming Ticket" button, it would trigger the popunder.
Can you help ?
In the current version of Google Chrome (21.0.1180.89) if the tab the pop under is originating from is not the last tab then the focus jumps to the next tab along. I think this is because in Chrome when you close a tab that has focus then the focus jumps to the next tab after the one that is being closed. I'm not sure if this issue existed in previous versions of Chrome.
Chrome 22 not working: popunder become pop up
Chrome 22: the popunder works the first time then it's always a pop up. Anyone else notice the same thing and is there any work around?
Sorry looks like its one of my extensions that causing it to popup. Works fine on other Chrome 22 installations.
For me, on Chrome 22 it also opens as a popup instead of popunder. :/
It was working on previous Chrome versions though.
I'm not longer updating the gist, because i created a repo for this:
https://github.com/hpbuniat/jquery-popunder
This version works on most chrome 22 installations, but it's not perfect yet. I'm still tinkering ;)
Hi,
I am Asp.net developer, I have used your script for popunder, I have called the pop under function in the <a> tag
( <a href="xxx.aspx" onclick="openpopunder()" >popunder</a> ) it works fine, But i have changed the
<script>
function openpopunder() {
jQuery.popunder('popunder-page.aspx');
window.location.href = "xxxxx.aspx";
}
</script>
( <a href="xxx.aspx" onclick="openpopunder()" >popunder</a> )
into
<asp:LinkButton ID="lnklogo" runat="server" OnClick="lnklogo_Click"><img src="./Images/xxxxxxx.png" alt="xxxxxxxx.com Logo" /></asp:LinkButton>
called the popup script in the code behind after saving my form values in Sessions
protected void lnklogo_Click(object sender, EventArgs e)
{
Session["formvalue"] = ObjFormvalue;
Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", "openpopunder()", true);
}
Now, This Scripts opens Pop UP Instead of Pop UNDER...
Any Idea? Please reply
Thanks,
Ragunath.s
i want to load this script, when my mouse hover on the browser window. can anyone help me.
If is self close and is pop under why you opened it in the first place_