简体   繁体   English

比什么更好<body onload=“javascript:showHide()”>

[英]Something better than <body onload=“javascript:showHide()”>

Guys I was wonder if I am doing something in an inefficient manner. 伙计们,我想知道我是否在以低效率的方式做某事。 Currently I am doing a <body onload='javascript: showHide(...etc..)'> . 目前,我正在执行<body onload='javascript: showHide(...etc..)'> In the JS function I basically hide elements based on class name I gave them. 在JS函数中,我基本上根据给定的类名隐藏元素。 But I have realized when I visit my website, just for just a short moment the elements that the JS showHide() function is intended to hide appear until the body of the page completely loads. 但是当我访问我的网站时,我已经意识到,只是短短一刻,JS showHide()函数打算隐藏的元素就会出现,直到页面正文完全加载为止。 Hopefully for my first website, intended to include in my resume, will not cost me that possible job opportunity.However, is there a better way to do what I am doing? 希望我的第一个网站(旨在包括在我的简历中)不会浪费我可能的工作机会,但是,有没有更好的方法来做我正在做的事情? I mean, I could just create completely dedicated pages for logged in users that are identical to the pages that non-subscribed users can view except for a few different elements; 我的意思是,我可以为登录用户创建完全专用的页面,该页面与非订阅用户可以查看的页面相同,除了一些不同的元素。 such as, links to view their account info, shopping cart, a log out link/icon, and a "logged in as: user name" display. 例如,用于查看其帐户信息的链接,购物车,注销链接/图标,以及“登录为:用户名”显示。 But I thought that would be too many web pages. 但是我认为那将是太多的网页。 Anyway thanks guys for any help. 无论如何,谢谢大家的帮助。

Did you think of doing it the other way around? 您是否想过反过来做? Hide elements first and then show elements based on a class name? 先隐藏元素,然后根据类名显示元素? This way, the elements will be hidden until the body of the page is loaded. 这样,元素将被隐藏,直到页面正文被加载为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM