Reputation: 29729
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 expected I do postback and then want to render correct site content.
Upvotes: 0
Views: 149
Reputation: 72672
What I would do is the following:
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.
Upvotes: 1
Reputation: 1014
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.
Upvotes: 2
Reputation: 3273
You can use $('body').hide()
, change body tag content with $('body').hide(content)
and then use $('body').show()
.
Upvotes: 1
Reputation: 35409
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...
Upvotes: 1