473,594 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling an id before he was created

Hi Guys
i need to call an ID before he was created cause i want to change his
display status (none:block) and i dont want to load him and only after
he was loaded to change his display settings.

i tried an unValid techniuqe- to write on the fly inside the body,
couse only there i can do so, a style tag that chage the display
definitions, but i cannot place a style tag inside the body.

any ideas?

Jan 11 '06 #1
28 1938
neoswf said the following on 1/11/2006 5:12 AM:
Hi Guys
i need to call an ID before he was created cause i want to change his
display status (none:block) and i dont want to load him and only after
he was loaded to change his display settings.


<style type="text/css">

#IDThatDoesntEx istYet{
display: none;
}
</style>

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 11 '06 #2
but this ID isnt exist yet
ill try to explain again- i use JS, and by JS i ask if and id exist. i
cannot ask if he exist if he havent been created yet in the HTML.

now u see my point?

*** Sent via Developersdex http://www.developersdex.com ***
Jan 11 '06 #3
neoswf wrote:
and only after he was loaded to change his display settings.


Do not do that. news:57******** ********@Pointe dEars.de
PointedEars
Jan 11 '06 #4
can you please explain your self and not just throw words to the air?
i need an assistence, can you support it? saying dont do this wont
solve my problem

Jan 11 '06 #5
VK

neoswf wrote:
Hi Guys
i need to call an ID before he was created cause i want to change his
display status (none:block) and i dont want to load him and only after
he was loaded to change his display settings.

i tried an unValid techniuqe- to write on the fly inside the body,
couse only there i can do so, a style tag that chage the display
definitions, but i cannot place a style tag inside the body.

any ideas?


You cannot do that - at least you cannot do that with any guarantees
that it will always work. Addressing an element by id (or by name for
this matter) is only possible when the DOM structure is ready. And the
DOM structure is not ready until "load" event for window is fired. Same
with desktop applications: you cannot open say a menu until the damn
thing is finished to open (who ever worked on slow machines knows what
I'm talking about).

So no again: you cannot handle something that doesn't exists yet.
Possible workarounds depend heavily on what conditions are you
showing/hiding page elements.
And remember that you cannot as well take any decisions in relation
with other elements (like "if element A contains this, then show
element B") You can check only basic conditions before "load": a
feature test, browser userAgent string, cookie presence, screen size
etc.

So what is your objective?

Jan 11 '06 #6
shlomi horovitz wrote:
but this ID isnt exist yet
Using CSS it doesn't matter. The CSS is parsed first (it must be in the
head, div's aren't allowed in the head).

When (if) the HTML parser finds the element, it will set its display
property to none because it's already been told to do that by the CSS.

ill try to explain again- i use JS, and by JS i ask if and id exist. i
cannot ask if he exist if he havent been created yet in the HTML.
Exactly. If it doesn't exist, you can't get a reference to it.

now u see my point?


We all got it the first time. If you want to use script to modify an
element, the soonest that the script can act is immediately *after* the
element has been created. Nothing you write can change that - 'the moving
parser having parsed moves on...' - apologies to Omar Khayyam and Edward
FitzGerald.

To do stuff to the DIV as soon as possible, put the script immediately
after the closing tag of the DIV in the HTML source:
<div id="hideMe">
<!-- stuff -->
</div>
<script type="text/javascript">
if (document.getEl ementById){
var hideMe = document.getEle mentById('hideM e');
}
hideMe && hideMe.style && hideMe.style.di splay = 'none';
</script>

--
Rob
Jan 11 '06 #7
RobG wrote:
[...]
<div id="hideMe">
<!-- stuff -->
</div>
<script type="text/javascript">
if (document.getEl ementById){
var hideMe = document.getEle mentById('hideM e');
}
hideMe && hideMe.style && hideMe.style.di splay = 'none';


Sorry, getting late...

hideMe && hideMe.style && (hideMe.style.d isplay = 'none');
The brackets are required to stop some browsers error-correcting the
assignment to an evaluation - i.e. changing '=' to '=='

--
Rob
Jan 11 '06 #8
neoswf wrote:
can you please explain your self and not just throw words to the air?
Follow the link -- Google Groups makes the news: URI one -- and read
what I posted before.
i need an assistence, can you support it? saying dont do this wont
solve my problem


You either do not have a problem at all but you create one with your
nonsensical approach, or you have more problems than you described.
PointedEars
Jan 11 '06 #9
first of all- thomas- i havent understood that the link u paste in your
messege is an article. it looked to me as kind of an Email, due to the
@PointedEars.de at the end of the link. please exept my appologies.

secondly, ill describe in details my problem: i have a site that in
some pages, i want to disapear the right OR left pannels.
so i display:none them using CSS.

so the solution i came up with is write a var and then write a function
that checks if the var = left OR right and the, using document.write,
ill write onThFly my CSS.

tommorow ill paste here the HTML page i created. its a template im very
proud of. its includes inside an html stracture that is very simple but
very powerfull.

Jan 11 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2208
by: Cindy Liu | last post by:
Hi Everyone, I created C# COM+ component. It has two overloaded methods - the method names are same and their signatures are different, one takes two parameters and another takes four. I coded this way: the method with 4 parameters is coded first and then the one with 2 parameters. I created very simple ASP page to call these two methods. Calling the method with 4 params has no problem. However, calling the method with 2 params I get the...
4
7272
by: Jerry Krinock | last post by:
I've written the following demo to help me understand a problem I'm having in a larger program. The "main" function constructs a Foo object, and then later "reconstructs" it by calling the constructor again. In my larger program, I find that the member variables don't get re-initialized when "reconstructed". I don't have that problem in this demo, but the second time the constructor is called, its "this" points to a different location. ...
6
3300
by: jchao123 | last post by:
Dear All, I have an MDB file (Access 2000/XP) which contains generic routines I use in various apps (eg, API calls, File access classes etc). I have compiled into an MDE file which I reference in VBA from my other Access applications. This works fine and I'm quite happy with it... except for one area; error handling. In most of my functions I call an error handler which
2
6604
by: mark | last post by:
I am developing an application in .Net C# that needs to restore a number of tool windows to some previous location and size. The problem I have is that when I create the form and set the Location and Size properties before calling the Show method, the form is not created in the Location that I set. If I call Show first everything works fine but there is excesive flicker when the Location and Size properties are set. I tried calling...
5
3410
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS 5), but fails on IIS 6 running on a Win2003 server. The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide some common functionality. The Page_Load handler the failing webpage starts out like this: ...
3
8539
by: Gary | last post by:
I am using VS.Net 2002 with windows 2000 advanced server and windows 2000 professional. I have a requirement to use windows service with a GUI. I want to show my own User Interface(Dialog) to get user input, before windows login screen. For that I have created a windows service, in the onstart event of this service, I am calling a vb.net exe, which has windows form. But it throws error bcoz of the form. I even tried by calling a vb.net...
5
1741
by: James Radke | last post by:
Hello, I am using VB.NET to call an unmanaged DLL which contains some functions. When I call the DLL from a windows application, it all works fine. When I place the same code in a webform application, my call to the first initialization routine simply hangs (i.e. in debugger it shows the code starts executing, but control never comes back to the debugger). This DLL uses the MFC42.DLL and MSVCRT.DLL which is in the WINNT/SYSTEM32...
4
1672
by: ST | last post by:
From Form1 I call a public sub in a module. The sub writes on Form1. Problem: the call creates a new Form1 and writes on it, instead of writing on the one already shown Form1. I have tried to avoid this by entering the following code at the beginning of the sub: Module Module1
3
5055
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb). I changed the data type for the structure that contains the XML data from the default "String" to "xml.xmldocument" to enable easy filling of the data. my client code creates an XML document class, fills the data using standard xml dom...
0
1358
by: han zhiyang | last post by:
I've just studied the "how to" web service and the async pattern in donnet.I make a test with these knowledges,but I got a strange result. Here is my test. 1.Write a simple "Add" service named MathWS( the class name),and put it in a ..asmx file named math.asmx in the "D:/winnt/interpub/wwwroot/mathws" directory. "mathws" is my new-built directory. 2.run the http://localhost/mathws/math.asmx,find it works well,and run run the...
0
7946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7877
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8003
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8240
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6659
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5410
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2387
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.