sandeep89
06-21-2005, 04:16 PM
i hope this is in the right place, when i've bin looking for help on this the term 'DOM' has been shown a lot, so i think its here, if not, please let me know...
now, this is probably going to be really easy for you guys, i don't think that its much of a mission for those who know how to use javascript and that, by k..
i have the following:
<body>
<h1>My name is sandeep</h1>
<p>blah blah blah <a href="http://www.google.com">dudududu</a> blah blah blah </p>
<script type="text/javascript">
if (document.getElementsByTagName="h1" & document.body.innerHTML.match("My name is sandeep"))
{
alert("its there")
}
else (document.getElementsByTagName="h1")
{
document.write("I am someone else")
}
</script>
</body>
k, as you can see here, i have text in heading1 (h1) saying 'my name is sandeep'. I want to be able to externally edit this text using javascript. I have been told that this is possible using innerhtml. I wasn't really sure what i was doing, but i thought i might need to get elements with the tag name of h1, and then use some sort of innerhtml replacing code.
however, it has to be conditional, so that if the 'My name is sandeep' text does not appear on the page, then nothing happens.
The results were left simple for now, if it was true then i tried to do it so it made a quick popup, and if it was wrong then it just says that its someone else...i want to have more javascript functions, but im sure that i can manage to do that after the rest is sorted.
If ne1 can help me with this, then i will be very thankful, bin struggling on this for a bout a week now, simply cos im a n00b to javascript programming like this.
thanks for readin, and helpin if you can
sandeep
now, this is probably going to be really easy for you guys, i don't think that its much of a mission for those who know how to use javascript and that, by k..
i have the following:
<body>
<h1>My name is sandeep</h1>
<p>blah blah blah <a href="http://www.google.com">dudududu</a> blah blah blah </p>
<script type="text/javascript">
if (document.getElementsByTagName="h1" & document.body.innerHTML.match("My name is sandeep"))
{
alert("its there")
}
else (document.getElementsByTagName="h1")
{
document.write("I am someone else")
}
</script>
</body>
k, as you can see here, i have text in heading1 (h1) saying 'my name is sandeep'. I want to be able to externally edit this text using javascript. I have been told that this is possible using innerhtml. I wasn't really sure what i was doing, but i thought i might need to get elements with the tag name of h1, and then use some sort of innerhtml replacing code.
however, it has to be conditional, so that if the 'My name is sandeep' text does not appear on the page, then nothing happens.
The results were left simple for now, if it was true then i tried to do it so it made a quick popup, and if it was wrong then it just says that its someone else...i want to have more javascript functions, but im sure that i can manage to do that after the rest is sorted.
If ne1 can help me with this, then i will be very thankful, bin struggling on this for a bout a week now, simply cos im a n00b to javascript programming like this.
thanks for readin, and helpin if you can
sandeep