hide everything on site
Is it possible to hide everything on site using jquery before it starts to be rendered ? I check query string and if something is as I expec开发者_JAVA技巧ted I do postback and then want to render correct site content.
You would be better to just hide the body by default then do your postback and after that append a class with a style of 'display:block;' - otherwise as javascript isn't loaded straight away, you may get a flash where it loads and then hides.
In the head you could do the following...
<head>
...
<script>$(function() { $(document.body).show(); });</script>
...
</>
In the body you can have the following...
<body>
<script>document.body.style.display = 'none';</script>
...
</body>
Using this approach will not produce a flash on the page...
You can use $('body').hide()
, change body tag content with $('body').hide(content)
and then use $('body').show()
.
What I would do is the following:
- Start the page without any content but an AJAX loader.
- Check the query string and let it return either the html or an object which states query string is invalid
- if valid load html in dom
- if invalid notify user
This way prevents users to see the content even if query string is invalid because they have disabled javascript.
Also just hiding stuff is bad, because users can just manipulate the DOM to show the elements.
精彩评论