/    Sign up×
Community /Pin to ProfileBookmark

HELP Javascript

Hello, I’m new here.
I have difficulty programming javascript … wanted to run the script after loading the page.

I have a object with a defined class “activator” and if i click them, it works…
But… how i put page loading “overlay” automatcly?
Thanks

[CODE]<div class=”content”>
<!– The activator –>
<a class=”activator” id=”activator” style=”left: 0px; top: 0px; width: 11px; height: 9px”></a>
</div>

<div class=”footer”>
</div>

<!– The overlay and the box –>
<div class=”overlay” id=”overlay” style=”display:none;”></div>
<div class=”box” id=”box”>
<a class=”boxclose” id=”boxclose”></a>
<h1>Escolha uma das seguintes opções</h1>
<p>
You have a new message
</p>
</div>

<!– The JavaScript –>
<script type=”text/javascript” src=”jquery-1.3.2.js”></script>
<script type=”text/javascript”>
$(function () {
$(‘#activator’).click(function(){
$(‘#overlay’).fadeIn(‘fast’,function(){
$(‘#box’).animate({‘top’:’160px’},500);
});
});
$(‘#boxclose’).click(function(){
$(‘#box’).animate({‘top’:’-200px’},500,function(){
$(‘#overlay’).fadeOut(‘fast’);
});
});
});
</script>
[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@brunotoiraauthorOct 04.2012 — Ok, done...

replace the code by this

it put's ESC key down working to hide overlay and autoload..

[CODE]<script type="text/javascript">
$(function () {
$('#activator').click(function(){
$('#overlay').fadeIn('fast',function(){
$('#box').animate({'top':'160px'},500);
});
});
$('#boxclose').click(function(){
$('#box').animate({'top':'-200px'},500,function(){
$('#overlay').fadeOut('fast');
});
});
});

$(document).keyup(function(e){
if(e.which == '27'){
//om when the ESC(27) key is pressed then will also close.
$('#box').animate({'top':'-200px'},500,function(){
$('#overlay').fadeOut('fast');
});
}
});

$(document).ready(function() {
$('#overlay').fadeIn('fast',function(){
$('#box').animate({'top':'160px'},500);
});
});
</script>[/CODE]
×

Success!

Help @brunotoira 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.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...