/    Sign up×
Community /Pin to ProfileBookmark

Looking for help with a simple script…

<script type=”text/javascript”>
window.onload=”element.hide(‘popup’);”
</script>

It doesn’t hide my div#popup currently – and I know I’m missing something basic. If you could clue me in that would be nice…thanks in advance.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@skywalker2208Dec 28.2008 — [code=php]

<script type="text/javascript">
window.onload=document.getElementById('popup').style.display='none';
</script>
[/code]
Copy linkTweet thisAlerts:
@johnnyblotterauthorDec 28.2008 — Just tried that. When the page loads the text from 'popup' is still there...it should be gone, right?
Copy linkTweet thisAlerts:
@atuchDec 28.2008 — window.onload is what is called an event handler since it handles the load event of the window object. Try the code below...

[code=html]
<script type="text/javascript">
window.onload=function() {
document.getElementById('popup').style.display='none';
}
</script>
[/code]
Copy linkTweet thisAlerts:
@johnnyblotterauthorDec 28.2008 — That does work. But why then does this NOT work?

[CODE]window.onload=function() {
alert("test");
}
[/CODE]
Copy linkTweet thisAlerts:
@atuchDec 30.2008 — I don't see why that wouldn't work. Maybe you need to clear your cache and then reload. It might not be loading the latest javascript changes you have made.
×

Success!

Help @johnnyblotter 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.2,
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,
)...