Skip to content

Instantly share code, notes, and snippets.

View noahub's full-sized avatar
💻
Doing computer stuff

Noah noahub

💻
Doing computer stuff
View GitHub Profile
@noahub
noahub / redirect_w_params.html
Created August 27, 2015 22:18
Redirect with URL parameters
<script>
var yourURL = 'http://www.google.com/';
var newURL = yourURL + location.search;
window.location = newURL;
</script>
@noahub
noahub / conversionClick.html
Last active August 29, 2015 14:21 — forked from johnnyopao/conversionClick.html
Adds targeted element as a Conversion Goal for your Unbounce landing page.
<script>
window.trackConversion = function() {
$('body').append('<iframe src="clkg/http/http/unbouncepages.com/blankpage/" style="display: none"></iframe>');
};
lp.jQuery(function($) {
$('#lp-pom-button-11').click(function () {
trackConversion();
});

Simple redirect to a URL:

<script type="text/javascript">
  window.location.replace('http://www.google.com/');
</script>

Redirect to a URL and pass through URL parameters and #anchor fragments

<script>
// unbounce-horizontal-forms 7453328
function HorizontalForm(a,b){var c=this;this.spacing=a,this.submitPlacement=b,this.$=window.lp.jQuery,this.$(function(){c.$form=c.$(".lp-pom-form").eq(0),c.$fields=c.$("div.lp-pom-form-field"),c.$button=c.$(".lp-pom-form .lp-pom-button").eq(0),"manual"!==c.submitPlacement&&(c.$fields=c.$fields.add(c.$button)),c.doLayout()}),this.$(window).resize(function(){c.doLayout()})}HorizontalForm.prototype.doLayout=function(){for(var a=this.$fields.eq(0).width()+this.spacing,b=this.$fields.eq(0).height(),c=this.$form.parent().width()-this.$form.position().left,d=0,e=0,f=0;f<this.$fields.length;f++){field=this.$fields.eq(f),e=0===f?e:e+a,e+a>c&&(d=0===f?d:d+b+this.spacing,e=0,b=field.height());var g=d;if(field.is(".lp-pom-button"))if("newline"===this.submitPlacement)g=d+b+spacing,e=0;else{g=d+19;var h=this.$form.find(":text").eq(0).height();field.css("height",h-1+"px")}else this.$(field).children("label").length||(g=d+19);field.css({top:g+"px",left:e+"px"}),field.height(
@noahub
noahub / ipad_scroll_no_dbl_scroll
Created June 24, 2015 16:12
iPad fancybox scroll fix
<style>
#fancybox-content {
overflow: auto;
-webkit-overflow-scrolling: touch !important;
}
</style>
@noahub
noahub / ajax_post.html
Created July 21, 2015 17:27
URL Parameter AJAX POST
<script>
//Replace #lp-pom-button-10 with your button's ID
$('#lp-pom-button-10').click(function() {
$.ajax({
type: 'POST',
data:(window.location.search.slice(1)),
url: 'http://requestb.in/pfyauwpf' //Replace this URL with your POST handler endpoint URL
});
});
@noahub
noahub / auto_submit_form.html
Last active August 29, 2015 14:26
Auto-Submit Form on page load
<script>
$(function() {
$(".lp-pom-form .lp-pom-button")[0].click();
});
</script>
@noahub
noahub / params_field_values.html
Created September 18, 2015 21:34
Grab Parameters and set form field values
<script>
//Function that stores parameters in array, returns parameter value
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
@noahub
noahub / url_param_grab.html
Created September 18, 2015 20:53
Parameter Grabber
<script>
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');