Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Hidden div content - CSS/JS

Name: Anonymous 2010-04-04 13:16

Is it possible to have content in a hidden div that doesn't load until it is revealed? I know you got dem answers /prog/.

Name: Anonymous 2010-04-04 13:21

Is it possible to have content in a hidden div that doesn't load until it is revealed? I have a page with content that is hidden until the correct link is clicked. This is a tidy solution, aesthetically, but I worry about the page load times. Is there any way to "pause" the div's loading until it is made visible by the link?
Thanks a lot.

Name: Anonymous 2010-04-04 13:27

Thanks a lot.

Name: Anonymous 2010-04-04 13:30

Read SICP.

Name: Anonymous 2010-04-04 13:53

AJAX

Name: Anonymous 2010-04-04 13:54

>>1-3
Oh please. You want us to do your heimarbeit for you? Take your .hidden-div { display: none; } and go back to Stack Overflow where it belongs.

Bunch of savages in this town.

Name: Anonymous 2010-04-04 15:44

It is possible with a jQuery plugin.

Name: Anonymous 2010-04-04 16:22

jQuery plugin
Implying peoples should code shit javascript with an even shittier javascript library.

>>1-kun:
You're looking for Ajax (though it's a stupid acronym nowadays because no one gives a fuck to load XML anymore and the request doesn't need to be asynchronous). Unfortunately, most of /prog/ won't be up to help you with ECMAScript.

Also, see >>4-kun, for he speaks words of wisdom, and stop spamming /prog/ with shit.

Name: Anonymous 2010-04-04 18:42

>>8
jQuery is pretty Javascripty. Don't go disparaging it just because you understand neither jQuery nor ECMAScript.

Name: Anonymous 2010-04-04 18:59

>>9
Implying I should consider a enterprise/fanboy library with so much design fails and bad coding style pretty javascript.

( ≖‿≖)

Name: Anonymous 2010-04-04 19:16

>>10
Could you possibly look any more pitiful within a single post?

Name: Anonymous 2010-04-05 1:35

put the content in a separate file and include it with an <object> tag inside the <div>. then it's up to the browser to decide when to load it and whether to do it synchronously or asynchronously. if the users don't like the way their browser does it, it's not your problem.

Name: Anonymous 2010-04-05 1:55

>>11
Go fuck yourself because it's not like someone else is going to do it.

Name: Anonymous 2010-04-05 3:32

>>12
That's a nice way to treat your user, anon!

Here's just one of the many ways to do it.


<html>
<head>
<title>jQuery Load Event Test</title>
</head>
<body>
<input type="button" value="Reveal Dat Div" />
<div id="reveal" style="display: none"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('body').bind('onReveal', function() {
        $('#reveal')
            .html('<img src="http://anime-wallpapers.com/images/1024x768/ash-and-pikachu.jpg" alt="loads when event is triggered" />')
            .show();
        /*
          if you want to wait until the content in that div is fully loaded before you show(),
          you'll need to attach load listeners to all the child img, script, iframe, etc.
          in this case, you're probably better off using ajax get() instead.
        */
    });
    $('input:button').click(function() {
        $('body').trigger('onReveal');
    });
});
</script>
</body>
</html>

Name: Anonymous 2010-04-05 4:16

>>14
giving your users a choice about when to load the content is better than telling them they have to do it a certain way, isn't it? and isn't making them sit and wait for it to load when the div is shown instead of starting to load it in the background a shitty thing to do?

Name: Anonymous 2010-04-05 7:00

document.write("<html>");

The rest is left as an exercise for the reader.

Name: Anonymous 2010-04-05 7:15

>>14
back to Stack Overflow, please

Name: Anonymous 2010-04-05 13:36

…………………...„„-~^^~„-„„_
………………„-^*'' : : „'' : : : : *-„
…………..„-* : : :„„--/ : : : : : : : '\
…………./ : : „-* . .| : : : : : : : : '|
……….../ : „-* . . . | : : : : : : : : |
………...\„-* . . . . .| : : : : : : : :'|
……….../ . . . . . . '| : : : : : : : :|
……..../ . . . . . . . .'\ : : : : : : : |
……../ . . . . . . . . . .\ : : : : : : :|
……./ . . . . . . . . . . . '\ : : : : : /
….../ . . . . . . . . . . . . . *-„„„„-*'
….'/ . . . . . . . . . . . . . . '|
…/ . . . . . . . ./ . . . . . . .|
../ . . . . . . . .'/ . . . . . . .'|
./ . . . . . . . . / . . . . . . .'|
'/ . . . . . . . . . . . . . . . .'|
'| . . . . . \ . . . . . . . . . .|
'| . . . . . . \„_^- „ . . . . .'|
'| . . . . . . . . .'\ .\ ./ '/ . |
| .\ . . . . . . . . . \ .'' / . '|
| . . . . . . . . . . / .'/ . . .|
| . . . . . . .| . . / ./ ./ . .|

Name: Anonymous 2010-04-05 13:41

>>16
document.write("</html>");

Don't change these.
Name: Email:
Entire Thread Thread List