• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Should this hide all in all browsers?

JosiahMaybe

Bronze Coder
Hello, trying to have a page entirely hidden, but then show specific elements by ID.
Would this part work in all browsers?
I have tested in Microsoft Edge on a computer.
JavaScript:
let count = 0;
while (count != document.body.children.length) {
    document.body.children[count].hidden=true;
    count++;
}
//X E
I know that works for a browser for hiding everything on a page on any page in Microsoft Edge on a computer.
Like my only question about it is if it runs on everything with an internet browser.
If it does not, what can?
Also I tested in Google Chrome on a computer too.
X E.
 
Last edited:
Solution
You could also use querySelectorAll.
JavaScript:
document.querySelectorAll("*").forEach(element => element.hidden = true);
So far like my research shows it should work in all modern browsers.
All browsers have document.body.
element.children is supported in all modern browsers seemingly.
element.hidden is always a property and may be changed.
element.hidden = true always means element is hidden.
Only possible problem may be like hiding a script or like that, and since those never show, just try and catch that element.hidden = thing.
I did find some older browsers may not support this element.children thing.
If that is then simply hide document.body.
With that absolutely nothing can be shown.
Hiding document.body is supported on all browsers, I am mostly sure.
Like document.body.hidden = true; is how.
If I am wrong on anything feel free to inform me.
I may just hide specific elements using ids but this is like my answer.
X E.
 
You could also use querySelectorAll.
JavaScript:
document.querySelectorAll("*").forEach(element => element.hidden = true);
 
Last edited:
Solution
Hello, trying to have a page entirely hidden, but then show specific elements by ID.
Would this part work in all browsers?
I have tested in Microsoft Edge on a computer.
JavaScript:
let count = 0;
while (count != document.body.children.length) {
    document.body.children[count].hidden=true;
    count++;
}
//X E
I know that works for a browser for hiding everything on a page on any page in Microsoft Edge on a computer.
Like my only question about it is if it runs on everything with an internet browser.
If it does not, what can?
Also I tested in Google Chrome on a computer too.
X E.
Hi there,
Question: why would you need to hide every element on a page?
 
I am trying to prevent possibility of selling and as with some systems I cannot get specific IDs (not like current found system to use now) hiding all elements prevents selling and is like most reliable way I know to prevent selling.
For things made in Javascript I can easily unhide or make them after done.
Result, no selling until like my coded elements do their thing, then I can hide some custom elements and show main view set again.
I found that even getElementById has its before existing in browsers so I may have to just hide using HTML and show using Javascript, if it works that is.
X E.
 

New Threads

Buy us a coffee!

300x250
Top Bottom