<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>DOM Example-1</title>
<script language="javascript" type="text/javascript">
function display() {
var xmldata1 = document.getElementById("xmldata1");
var bizCard = xmldata1.getElementsByTagName("BusinessCard")[0];
var name = bizCard.getElementsByTagName("Name")[0].firstChild.data;
aler("Name : " + name);
}
</script>
</head>
<body>
<xml id="xmldata1" style="display:none">
<BusinessCard>
<Name>Joe Marini</Name>
<phone type="mobile">(415) 555-4567</phone>
<phone type="work">(800) 555-9876</phone>
<phone type="fax">(510) 555-1234</phone>
<email>joe@joe.com</email>
</BusinessCard>
</xml>
<a href="java script:display()">Display Businesscard</a>
</body>
</html>
xml and javascript
Page 1 of 14 Replies - 605 Views - Last Post: 15 December 2008 - 05:46 PM
#1
xml and javascript
Posted 15 December 2008 - 11:46 AM
What is wrong with this code ????
Replies To: xml and javascript
#2
Re: xml and javascript
Posted 15 December 2008 - 11:48 AM
What is wrong with this code ????
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>DOM Example-1</title>
<script language="javascript" type="text/javascript">
function display() {
var xmldata1 = document.getElementById("xmldata1");
var bizCard = xmldata1.getElementsByTagName("BusinessCard")[0];
var name = bizCard.getElementsByTagName("Name")[0].firstChild.data;
aler("Name : " + name);
}
</script>
</head>
<body>
<xml id="xmldata1" style="display:none">
<BusinessCard>
<Name>Joe Marini</Name>
<phone type="mobile">(415) 555-4567</phone>
<phone type="work">(800) 555-9876</phone>
<phone type="fax">(510) 555-1234</phone>
<email>joe@joe.com</email>
</BusinessCard>
</xml>
<a href="java script:display()">Display Businesscard</a>
</body>
</html>
#3
Re: xml and javascript
Posted 15 December 2008 - 12:22 PM
No "t" in alert and a space between java and script in the href.
#4
Re: xml and javascript
Posted 15 December 2008 - 01:56 PM
NOTE: This might be a little bug in this rich text editor.
I tried entering the same <a href=...> tag (within the code tag) in this editor and it put a space between java & script (java script)
Strange.
I tried entering the same <a href=...> tag (within the code tag) in this editor and it put a space between java & script (java script)
Strange.
This post has been edited by JohnWaters: 15 December 2008 - 01:58 PM
#5
Re: xml and javascript
Posted 15 December 2008 - 05:46 PM
Please don't post duplicate topics. Merged.
No, that isn't a bug. It separates Java and Script to avoid html/JS based security issues (like links that try to do strange things and so forth).
Not sure what it is supposed to do, but you do have a typo in "aler" < notice the missing "t"
Again, I wasn't really sure what you were trying for.
Hope that helps.
Quote
NOTE: This might be a little bug in this rich text editor.
No, that isn't a bug. It separates Java and Script to avoid html/JS based security issues (like links that try to do strange things and so forth).
Not sure what it is supposed to do, but you do have a typo in "aler" < notice the missing "t"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>DOM Example-1</title>
<script language="javascript" type="text/javascript">
function display() {
var xmldata1 = document.getElementById("xmldata1");
var bizCard = xmldata1.getElementsByTagName("BusinessCard")[0];
var name = bizCard.getElementsByTagName("Name")[0].firstChild.data;
alert("Name : " + name);
}
</script>
</head>
<body>
<xml id="xmldata1" style="display:none">
<BusinessCard>
<Name>Joe Marini</Name>
<phone type="mobile">(415) 555-4567</phone>
<phone type="work">(800) 555-9876</phone>
<phone type="fax">(510) 555-1234</phone>
<email>joe@joe.com</email>
</BusinessCard>
</xml>
<a href="java script:display()">Display Businesscard</a>
</body>
</html>
Again, I wasn't really sure what you were trying for.
Hope that helps.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|