Javascript 全屏悬停注册框——如squarespace上所示
我喜欢他们的注册过程——当你点击“从这个模板开始”时,整个视口都被占据了,注册框就会出现Javascript 全屏悬停注册框——如squarespace上所示,javascript,Javascript,我喜欢他们的注册过程——当你点击“从这个模板开始”时,整个视口都被占据了,注册框就会出现 有人知道有一个脚本已经做了类似的事情吗?这被称为模态窗口。您可以使用Java或JavaScript实现它。对于一个简单的开始,您可以查看由的提供的教程 代码非常简单。首先,您必须构建HTML <!-- #dialog is the id of a DIV defined in the code below --> <a href="#dialog" name="modal">Simp
有人知道有一个脚本已经做了类似的事情吗?这被称为模态窗口。您可以使用Java或JavaScript实现它。对于一个简单的开始,您可以查看由的提供的教程 代码非常简单。首先,您必须构建HTML
<!-- #dialog is the id of a DIV defined in the code below -->
<a href="#dialog" name="modal">Simple Modal Window</a>
<div id="boxes">
<!-- #customize your modal window here -->
<div id="dialog" class="window">
<b>Testing of Modal Window</b> |
<!-- close button is defined as close class -->
<a href="#" class="close">Close it</a>
</div>
<!-- Do not remove div#mask, because you'll need it to fill the whole screen -->
<div id="mask"></div>
</div>
最后,JavaScript用于交互
$(document).ready(function() {
//select all the a tag with name equal to modal
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $(this).attr('href');
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set height and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
});
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask, .window').hide();
});
//if mask is clicked
$('#mask').click(function () {
$(this).hide();
$('.window').hide();
});
});
您可以在中看到此项目的工作演示。单击该页面上的
Simple Window model
链接。这称为model Window。您可以使用Java或JavaScript实现它。对于一个简单的开始,您可以查看由的提供的教程
代码非常简单。首先,您必须构建HTML
<!-- #dialog is the id of a DIV defined in the code below -->
<a href="#dialog" name="modal">Simple Modal Window</a>
<div id="boxes">
<!-- #customize your modal window here -->
<div id="dialog" class="window">
<b>Testing of Modal Window</b> |
<!-- close button is defined as close class -->
<a href="#" class="close">Close it</a>
</div>
<!-- Do not remove div#mask, because you'll need it to fill the whole screen -->
<div id="mask"></div>
</div>
最后,JavaScript用于交互
$(document).ready(function() {
//select all the a tag with name equal to modal
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $(this).attr('href');
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set height and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
});
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask, .window').hide();
});
//if mask is clicked
$('#mask').click(function () {
$(this).hide();
$('.window').hide();
});
});
您可以在中看到此项目的工作演示。单击该页面上的
Simple Window model
链接。使用简单的javascript可以非常轻松地完成此操作
HTML:
Javascript(jQuery):
您可以单击覆盖以退出窗口
看 使用简单的javascript,您可以非常轻松地完成此任务 HTML: Javascript(jQuery): 您可以单击覆盖以退出窗口
看 我在寻找类似情况时遇到了这个问题。我有一段自定义javascript代码,用于我的SS6站点。你必须原谅我,因为我是一名设计师&而不是开发人员 有关地点: 目前,在用户单击“Count Me In”后,会出现一个弹出窗口,允许该用户注册。一切都很好,但弹出窗口只是一个带有一些输入字段的.png文件&一个提交按钮——不是很优雅,也没有响应能力。我想用一个使背景变暗的模式来替换弹出窗口,这个线程看起来是开始解决我的方法的正确位置。顺便说一句,代码是内联的,并格式化为适合SS代码块 javascript小部件的代码:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="https://www.parsecdn.com/js/parse-1.0.19.min.js"></script>
<style>
.bgimg {
background-image: url("/s/bluebk.jpg");
}
#overlay_form{
position:relative;
-moz-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
border: 0px solid black;
width: 640px;
height: 340px;
background-image: url("https://static.squarespace.com/static/532ccd30e4b00d0eac2a448c/t/533acaffe4b0cd1c8b92271c/1396361983567/tenfortenpopup.png");
background-repeat:no-repeat;
background-size: 100% 100%;
overflow:Hidden;
margin:0px auto;
margin-top: -344px !important;
}
.slemail{
border:0px solid white;
font-size: 22px !important;
width: 310px;
height: 40px;
font-family: "Futura-pt";
color:#ababab;
-moz-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
position: absolute;
left: 34px;
bottom: 20px;
-webkit-appearance : none;
padding-left:5px;
}
.countertext{
font-family: "futura-pt";
text-transform: uppercase;
letter-spacing: 4px;
color:white;
font-size: 52.55px;
font-weight: 700;
font-style: normal;
line-height: 1;
text-align: center;
margin: 0px, auto;
margin-top: 24px;
}
.counternumber {
font-family: "futura-pt";
text-transform: uppercase;
letter-spacing: 0px;
color:white;
font-size: 100.55px;
padding:3px;
display: inline-block;
line-height: 100%;
font-weight: 700;
font-style: normal;
background: none !important;
margin-left: auto;
margin-right: auto;
margin-top: -5px;
}
.hitme {
-webkit-border-radius: 45px;
-moz-border-radius: 45px;
border-radius: 4px;
border: solid 1px Black;
display:inline-block;
width: 70%;
line-height: 1.482;
text-align: center;
font-family: "futura-pt";
font-size: 38.28px;
font-weight: 400;
font-style: normal;
background-color:#343e3d;
color:white;
letter-spacing:2px;
text-transform: uppercase;
margin: 0px, auto;
margin-top: 13px;
}
.hitmesmall:active { right: 38px }
.hitmesmall {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
display:inline-block;
width: 200px;
padding:2px 10px;
font-family: "futura-pt";
font-size: 22px;
background-color:#666666;
color:white;
letter-spacing:1px;
height:41px;
position: absolute;
right: 40px;
bottom: 20px;
border: solid 0px #343e3d;
}
input:focus{
outline:none;
}
.exitpopup
{
position: absolute;
right: 5px;
top: 4px;
}
</style>
<script TYPE="text/javascript">
//mailchimp javascript block
////////////////////////////
//Ten for Ten
var arr = {
apikey: "3865eadb82f9d9951067ff814b6fe34a-us4",
id: "9f12ac9801",
double_optin:"false",
email:{
email: "replacewithemail"
}
}
var url = "https://us4.api.mailchimp.com/2.0/lists/subscribe.json";
function mailchimp_addemail($email)
{
arr.email.email = $email;
$.ajax({
type: "GET",
url: url,
contentType: "application/json",
async: false,
cache: false,
dataType: "jsonp",
data: arr,
complete: function(jqXHR, textStatus){
// alert("Mailchimp added");
}
})
return false;
}
// end mailchimp javascript block
</script>
<script TYPE="text/javascript">
//popup javascript block
////////////////////////
function validateEmail($email)
{
var re = /\S+@\S+\.\S+/;
return re.test($email);
}
function openpopup()
{
$("#overlay_form").fadeIn(10);
$('#subscriberemail').focus();
$('#subscriberemail').val("your@email.com");
just_count();
return false;
}
function closepopup()
{
$("#overlay_form").fadeOut(10);
return false;
}
function subscribe()
{
var $email = $('#subscriberemail').val();
var $checkme = $email.toLowerCase();
if ( validateEmail($checkme) == false)
{
$('#subscriberemail').val("your@email.com");
$('#subscriberemail').focus();
return false;
}
if ( $checkme == "your@email.com" )
{
$('#subscriberemail').val("your@email.com");
$('#subscriberemail').focus();
return false;
}
// kick off the parse.com stuff
// the mailchimp call gets made on success
parse_add($email);
return false;
}
//end popup javascript block
</script>
<script TYPE="text/javascript">
//generic javascript block
// parse.com Appid and jskey
////////////////////////
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
//Ten For Ten
var parseappid = "I8bjfDP5GK8UKA509BFUQAsTRmHHgocl1ppSAwDO";
var parsejskey = "JxvgeMDJQuHCwinZjq8TBEJmx1KUd3EwtcOmSr3e";
var subscriber;
var sequence;
$( document ).ready(function() {
Parse.initialize(parseappid, parsejskey);
subscriber = Parse.Object.extend("subscriber");
sequence = Parse.Object.extend("sequence");
// lets init the subscriber count
parse_initcount();
});
</script>
<script TYPE="text/javascript">
//parse.com javascript block
////////////////////////////
function parse_addemail($email)
{
var addsubscriber = new subscriber();
addsubscriber.set("email", $email);
addsubscriber.save(null, {
success: function(object) {
parse_incrementcount();
mailchimp_addemail($email);
},
error: function(error) {
alert("parse_addemail :" + error);
}
});
};
function just_count()
{
var query = new Parse.Query(sequence);
query.get("FJ2FWGWED6", {
success: function(object)
{
object.increment("counter");
object.save();
var s = object.get("counter");
var display = numberWithCommas(s);
$("#curcount").html(display);
},
error: function(error)
{
alert("parse_incrementcount :" + error);
}
});
};
function parse_incrementcount()
{
var query = new Parse.Query(sequence);
query.get("FJ2FWGWED6", {
success: function(object)
{
},
error: function(error)
{
alert("parse_incrementcount :" + error);
}
});
};
function parse_initcount()
{
var query = new Parse.Query(sequence);
query.get("FJ2FWGWED6", {
success: function(object)
{
var s = object.get("counter");
var display = numberWithCommas(s);
$("#curcount").html(display);
},
error: function(error)
{
alert("parse_initcount: " + error);
}
});
};
// this is called on from hitmesmall submit onclick
///////////////////////////////////////////////////
function parse_add($email)
{
var query = new Parse.Query(subscriber);
query.equalTo("email", $email);
query.find({
success: function(object) {
if ( object.length == 0 )
{
parse_addemail($email);
$('#subscriberemail').val("Congrats! Thanks for Pledging!");
} else {
$('#subscriberemail').val("Email already Subscribed !");
$('#subscriberemail').focus();
}
}, error: function(error) {
alert("parse_add: " + error);
}
});
};
//end parse.com javascript block
</script>
</head>
<body>
<div class="bgimg" align=center>
<br>
<span class="counternumber" id="curcount">0</span>
<br>
<span class="countertext" id="pledged">PEOPLE HAVE PLEDGED! </span>
<br>
<button class="hitme" id="subscribe" onclick="return openpopup() ">COUNT ME IN!</button>
<br>
<br>
<br>
</div>
<!-- popup form -->
<div id="overlay_form" style="display:none">
<input id="subscriberemail" class="slemail" type="text" value="your@email.com"/>
<button id="addemail" class="hitmesmall" onclick="return subscribe()" >SUBMIT</button>
<button id="exitpopup" class="exitpopup" onclick="return closepopup()">X</button>
</div>
</body>
</html>
.bgimg{
背景图片:url(“/s/bluebk.jpg”);
}
#重叠式{
位置:相对位置;
-moz边界半径:4px;
-webkit边界半径:4px;
边界半径:4px;
边框:0px纯黑;
宽度:640px;
高度:340px;
背景图像:url(“https://static.squarespace.com/static/532ccd30e4b00d0eac2a448c/t/533acaffe4b0cd1c8b92271c/1396361983567/tenfortenpopup.png");
背景重复:无重复;
背景大小:100%100%;
溢出:隐藏;
保证金:0px自动;
页边顶部:-344px!重要;
}
斯莱梅尔先生{
边框:0px纯白;
字体大小:22px!重要;
宽度:310px;
高度:40px;
字体系列:“Futura pt”;
颜色:#阿巴巴;
-moz边界半径:4px;
-webkit边界半径:4px;
边界半径:4px;
位置:绝对位置;
左:34px;
底部:20px;
-webkit外观:无;
左侧填充:5px;
}
.反文本{
字体系列:“futura pt”;
文本转换:大写;
字母间距:4px;
颜色:白色;
字体大小:52.55px;
字号:700;
字体风格:普通;
线高:1;
文本对齐:居中;
保证金:0px,自动;
利润上限:24px;
}
.柜台号码{
字体系列:“futura pt”;
文本转换:大写;
字母间距:0px;
颜色:白色;
字体大小:100.55px;
填充:3倍;
显示:内联块;
线高:100%;
字号:700;
字体风格:普通;
背景:无!重要;
左边距:自动;
右边距:自动;
页边顶部:-5px;
}
hitme先生{
-webkit边界半径:45px;
-moz边界半径:45px;
边界半径:4px;
边框:实心1px黑色;
显示:内联块;
宽度:70%;
线高:1.482;
文本对齐:居中;
字体系列:“futura pt”;
字号:38.28px;
字体大小:400;
字体风格:普通;
背景色:#343e3d;
颜色:白色;
字母间距:2px;
文本转换:大写;
保证金:0px,自动;
边缘顶端:13px;
}
.hitmesmall:活动{右:38px}
hitmesmall先生{
-webkit边界半径:4px;
-moz边界半径:4px;
边界半径:4px;
显示:内联块;
宽度:200px;
填充:2x10px;
字体系列:“futura pt”;
字体大小:22px;
背景色:#666666;
颜色:白色;
字母间距:1px;
高度:41px;
位置:绝对位置;
右:40px;
底部:20px;
边框:实心0px#343e3d;
}
输入:焦点{
大纲:无;
}
.exitpopup
{
位置:绝对位置;
右:5px;
顶部:4px;
}
//mailchimp javascript块
////////////////////////////
//十有八九
var arr={
apikey:“3865eadb82f9d9951067ff814b6fe34a-us4”,
id:“9f12ac9801”,
双选项:“假”,
电邮:{
电子邮件:“替换为电子邮件”
}
}
变量url=”https://us4.api.mailchimp.com/2.0/lists/subscribe.json";
函数mailchimp_addemail($email)
{
arr.email.email=$email;
$.ajax({
键入:“获取”,
url:url,
contentType:“应用程序/json”,
async:false,
cache:false,
数据类型:“jsonp”,
数据:arr,
完成:函数(jqXHR,textStatus){
//警报(“Mailchimp添加”);
}
})
返回false;
}
//结束mailchimp javascript块
//弹出javascript块
////////////////////////
函数validateEmail($email)
$(function(){
$('#trigger').click(function(){
$('#login').fadeIn(500);
$('#overlay').fadeIn(500);
});
$('#overlay').click(function(){
$('#login').fadeOut(500);
$('#overlay').fadeOut(500);
});
});
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="https://www.parsecdn.com/js/parse-1.0.19.min.js"></script>
<style>
.bgimg {
background-image: url("/s/bluebk.jpg");
}
#overlay_form{
position:relative;
-moz-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
border: 0px solid black;
width: 640px;
height: 340px;
background-image: url("https://static.squarespace.com/static/532ccd30e4b00d0eac2a448c/t/533acaffe4b0cd1c8b92271c/1396361983567/tenfortenpopup.png");
background-repeat:no-repeat;
background-size: 100% 100%;
overflow:Hidden;
margin:0px auto;
margin-top: -344px !important;
}
.slemail{
border:0px solid white;
font-size: 22px !important;
width: 310px;
height: 40px;
font-family: "Futura-pt";
color:#ababab;
-moz-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
position: absolute;
left: 34px;
bottom: 20px;
-webkit-appearance : none;
padding-left:5px;
}
.countertext{
font-family: "futura-pt";
text-transform: uppercase;
letter-spacing: 4px;
color:white;
font-size: 52.55px;
font-weight: 700;
font-style: normal;
line-height: 1;
text-align: center;
margin: 0px, auto;
margin-top: 24px;
}
.counternumber {
font-family: "futura-pt";
text-transform: uppercase;
letter-spacing: 0px;
color:white;
font-size: 100.55px;
padding:3px;
display: inline-block;
line-height: 100%;
font-weight: 700;
font-style: normal;
background: none !important;
margin-left: auto;
margin-right: auto;
margin-top: -5px;
}
.hitme {
-webkit-border-radius: 45px;
-moz-border-radius: 45px;
border-radius: 4px;
border: solid 1px Black;
display:inline-block;
width: 70%;
line-height: 1.482;
text-align: center;
font-family: "futura-pt";
font-size: 38.28px;
font-weight: 400;
font-style: normal;
background-color:#343e3d;
color:white;
letter-spacing:2px;
text-transform: uppercase;
margin: 0px, auto;
margin-top: 13px;
}
.hitmesmall:active { right: 38px }
.hitmesmall {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
display:inline-block;
width: 200px;
padding:2px 10px;
font-family: "futura-pt";
font-size: 22px;
background-color:#666666;
color:white;
letter-spacing:1px;
height:41px;
position: absolute;
right: 40px;
bottom: 20px;
border: solid 0px #343e3d;
}
input:focus{
outline:none;
}
.exitpopup
{
position: absolute;
right: 5px;
top: 4px;
}
</style>
<script TYPE="text/javascript">
//mailchimp javascript block
////////////////////////////
//Ten for Ten
var arr = {
apikey: "3865eadb82f9d9951067ff814b6fe34a-us4",
id: "9f12ac9801",
double_optin:"false",
email:{
email: "replacewithemail"
}
}
var url = "https://us4.api.mailchimp.com/2.0/lists/subscribe.json";
function mailchimp_addemail($email)
{
arr.email.email = $email;
$.ajax({
type: "GET",
url: url,
contentType: "application/json",
async: false,
cache: false,
dataType: "jsonp",
data: arr,
complete: function(jqXHR, textStatus){
// alert("Mailchimp added");
}
})
return false;
}
// end mailchimp javascript block
</script>
<script TYPE="text/javascript">
//popup javascript block
////////////////////////
function validateEmail($email)
{
var re = /\S+@\S+\.\S+/;
return re.test($email);
}
function openpopup()
{
$("#overlay_form").fadeIn(10);
$('#subscriberemail').focus();
$('#subscriberemail').val("your@email.com");
just_count();
return false;
}
function closepopup()
{
$("#overlay_form").fadeOut(10);
return false;
}
function subscribe()
{
var $email = $('#subscriberemail').val();
var $checkme = $email.toLowerCase();
if ( validateEmail($checkme) == false)
{
$('#subscriberemail').val("your@email.com");
$('#subscriberemail').focus();
return false;
}
if ( $checkme == "your@email.com" )
{
$('#subscriberemail').val("your@email.com");
$('#subscriberemail').focus();
return false;
}
// kick off the parse.com stuff
// the mailchimp call gets made on success
parse_add($email);
return false;
}
//end popup javascript block
</script>
<script TYPE="text/javascript">
//generic javascript block
// parse.com Appid and jskey
////////////////////////
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
//Ten For Ten
var parseappid = "I8bjfDP5GK8UKA509BFUQAsTRmHHgocl1ppSAwDO";
var parsejskey = "JxvgeMDJQuHCwinZjq8TBEJmx1KUd3EwtcOmSr3e";
var subscriber;
var sequence;
$( document ).ready(function() {
Parse.initialize(parseappid, parsejskey);
subscriber = Parse.Object.extend("subscriber");
sequence = Parse.Object.extend("sequence");
// lets init the subscriber count
parse_initcount();
});
</script>
<script TYPE="text/javascript">
//parse.com javascript block
////////////////////////////
function parse_addemail($email)
{
var addsubscriber = new subscriber();
addsubscriber.set("email", $email);
addsubscriber.save(null, {
success: function(object) {
parse_incrementcount();
mailchimp_addemail($email);
},
error: function(error) {
alert("parse_addemail :" + error);
}
});
};
function just_count()
{
var query = new Parse.Query(sequence);
query.get("FJ2FWGWED6", {
success: function(object)
{
object.increment("counter");
object.save();
var s = object.get("counter");
var display = numberWithCommas(s);
$("#curcount").html(display);
},
error: function(error)
{
alert("parse_incrementcount :" + error);
}
});
};
function parse_incrementcount()
{
var query = new Parse.Query(sequence);
query.get("FJ2FWGWED6", {
success: function(object)
{
},
error: function(error)
{
alert("parse_incrementcount :" + error);
}
});
};
function parse_initcount()
{
var query = new Parse.Query(sequence);
query.get("FJ2FWGWED6", {
success: function(object)
{
var s = object.get("counter");
var display = numberWithCommas(s);
$("#curcount").html(display);
},
error: function(error)
{
alert("parse_initcount: " + error);
}
});
};
// this is called on from hitmesmall submit onclick
///////////////////////////////////////////////////
function parse_add($email)
{
var query = new Parse.Query(subscriber);
query.equalTo("email", $email);
query.find({
success: function(object) {
if ( object.length == 0 )
{
parse_addemail($email);
$('#subscriberemail').val("Congrats! Thanks for Pledging!");
} else {
$('#subscriberemail').val("Email already Subscribed !");
$('#subscriberemail').focus();
}
}, error: function(error) {
alert("parse_add: " + error);
}
});
};
//end parse.com javascript block
</script>
</head>
<body>
<div class="bgimg" align=center>
<br>
<span class="counternumber" id="curcount">0</span>
<br>
<span class="countertext" id="pledged">PEOPLE HAVE PLEDGED! </span>
<br>
<button class="hitme" id="subscribe" onclick="return openpopup() ">COUNT ME IN!</button>
<br>
<br>
<br>
</div>
<!-- popup form -->
<div id="overlay_form" style="display:none">
<input id="subscriberemail" class="slemail" type="text" value="your@email.com"/>
<button id="addemail" class="hitmesmall" onclick="return subscribe()" >SUBMIT</button>
<button id="exitpopup" class="exitpopup" onclick="return closepopup()">X</button>
</div>
</body>
</html>