Web Design Web Design Forum
Registration is free! Here you can view your subscribed threads, work with private messages and edit your profile and preferences Calendar Find other members Frequently Asked Questions Search
Home Web Design

Convenient web based access to our favorite web design Usenet groups

web design reviews

This is Interesting: Free Magazines for Graphics designers and webmasters  





  Last Thread  Next Thread
Author
Thread Post New Thread   

Check if document ID exists?
 

michael




quote this post edit post

IP Loged report this post

Old Post  06-23-04 - 09:15 AM  
I guess this is partly a javascript questions, but is there a way to check
if a CSS id or class exists anywhere on a page.

For example, if the id "bla" exists, it should return true only if the
following tag is on the page:

<a href="bla.html" id="bla">



Post Follow-Up to this message ]
Re: Check if document ID exists?
 

DU




quote this post edit post

IP Loged report this post

Old Post  06-23-04 - 09:15 AM  
michael wrote:

> I guess this is partly a javascript questions, but is there a way to check
> if a CSS id or class exists anywhere on a page.
>
> For example, if the id "bla" exists, it should return true only if the
> following tag is on the page:
>
> <a href="bla.html" id="bla">
>

In the above code, id is an HTML attribute name and "bla" is an HTML
attribute value.


"getElementById introduced in DOM Level 2
Returns the Element whose ID is given by elementId. If no such
element exists, returns null."
[url]http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-getElBId[/url
]

So,
if(document.getElementById("bla"))
{
.. [instructions if it exists];
}
else
{
.. [instructions if it does not exist];
};

DU


Post Follow-Up to this message ]
Re: Check if document ID exists?
 

Harlan Messinger




quote this post edit post

IP Loged report this post

Old Post  06-23-04 - 05:19 PM  
michael <nomail@example.com> wrote:

>I guess this is partly a javascript questions, but is there a way to check
>if a CSS id or class exists anywhere on a page.

The id and class attributes are HTML element attributes, not CSS.

>
>For example, if the id "bla" exists, it should return true only if the
>following tag is on the page:
>
><a href="bla.html" id="bla">

if (document.getElementById("bla") == null) ...

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ๔ter le premier point de mon adresse de courriel.


Post Follow-Up to this message ]
Re: Check if document ID exists?
 

michael




quote this post edit post

IP Loged report this post

Old Post  06-23-04 - 05:19 PM  
> if (document.getElementById("bla") == null) ...

Perfect - Thanks ! ! !



Post Follow-Up to this message ]
Sponsored Links
 





All times are GMT. The time now is 04:25 AM. Post New Thread   
  Previous Last Thread   Next Thread next
Stylesheets archive | Show Printable Version | Email this Page | Subscribe to this Thread

Popular forums

Adobe Photoshop forum Macromedia Flash Web Site Design
Dreamweaver FrontPage forum
JavaScript Forum XML forum
Style Sheets VRML
Forum Jump:
Rate This Thread:

 

XML RSS Feed web design latest articles Syndicate our forum via XML or simple JavaScript

Web Design archive  Database administration help  


Top Home  -  Register  -  Control Panel   -  Memberlist  -  Calendar  -  Faq  -  Search Top