Hi All ,
Well as the title suggests i am trying to implment a javascript based slideshow which reads of an xml file and displays the pictures the xml file also contains a link for each image element which is displayed when the user clicks ona particular image.The code was embedded in my aspx page but it does n't work , during my past uncountable attempts to view the script in Firefox or IE i get this error
Error: document.images.slide has no properties
Source File: Line: 95
I am just a newbie to javascripts and have very recently recognised the potential power of them . I would be very greatfull if someone could please help me fix this error as i can feel it that the code is not too far from what it's meant to accomplish as i have managed to read of my xml file and display the content as an html table and i have manged to display and animation based on some passign in some pictures' url and links as array to my functions. Any help would be very highly appreciated .
<script type="text/javascript" language="javascript" >
// JScript File
var xmlDoc ;
var slideimages=new Array(10);
var slidelinks=new Array(10);
var slideshowspeed=2000
var whichlink=0
var whichimage=0
function importXML()
{ alert('inside importXML 1');
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = createTable;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4) createTable()
};
}
else
{
alert('Your browser can\'t handle this script');
return;
}
xmlDoc.load("Top_Animation.xml");
}
function createTable()
{
var x = xmlDoc.getElementsByTagName('Image');
for (i=0;i<x.length;i++)
{
for (j=0;j<x.childNodes.length;j++)
{
if (x.childNodes[j].nodeType != 1) continue;
if (j=0)
{
document.images.item['slide']= x.childNodes[j].firstChild.nodeValue
slideshowimages(x.childNodes[j].firstChild.nodeValue);
}
if (j=1)
{
slideshowlinks(x.childNodes[j].firstChild.nodeValue);
}
}
}
}
function gotoshow()
{ importXML();
if (!window.winslide||winslide.closed)
winslide=window.open(slidelinks[whichlink])
else
winslide.location=slidelinks[whichlink]
winslide.focus()
}
function slideshowimages()
{
for (i=0;i<slideshowimages.arguments.length;i++)
{
slideimages=new Image()
slideimages.src=slideshowimages.arguments
}
}
function slideshowlinks()
{
for (i=0;i<slideshowlinks.arguments.length;i++)
slidelinks=slideshowlinks.arguments
}
function slideit()
{
if (!document.images)
return
document.images.slide.src=slideimages[whichimage].src
whichlink=whichimage
if (whichimage<slideimages.length-1)
whichimage++
else
whichimage=0
setTimeout("slideit()",slideshowspeed)
}
slideit()
</script>
<body >
<a href="javascript:gotoshow();"><img alt="animated banner" src=" id="slide"/></a>
My xml file looks like
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="Top_Animation.xsl"?>
<Images xmlns:xsi="xsi:schemaLocation=" <Image>
<URL>
</URL>
<Link>
</Link>
</Image>
<Image>
<URL>
</URL>
<Link>
</Link>
</Image>
<Image>
<URL>
</URL>
<Link>
</Link>
</Image>
<Image>
<URL>
</URL>
<Link>
</Link>
</Image>
<Image>
<URL>
</URL>
<Link>
</Link>
</Image>
</Images>
my xss file looks like
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Images" xmlns="" xmlns:xs=" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Images" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Image">
<xs:complexType>
<xs:sequence>
<xs:element name="URL" type="xs:string" minOccurs="0" />
<xs:element name="Link" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
My xsl file looks something like this
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="
<xsl:template match="/">
<html>
<body>
<!--
This is an XSLT template file. Fill in this area with the
XSL elements which will transform your XML to XHTML.
-->
<h2>My Images</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">URL</th>
<th align="left">Link</th>
</tr>
<xsl:for-each select="Images/Image">
<tr>
<td>
<xsl:value-of select="URL"/>
</td>
<td>
<xsl:value-of select="Link"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Thanxs in advance !
Well as the title suggests i am trying to implment a javascript based slideshow which reads of an xml file and displays the pictures the xml file also contains a link for each image element which is displayed when the user clicks ona particular image.The code was embedded in my aspx page but it does n't work , during my past uncountable attempts to view the script in Firefox or IE i get this error
Error: document.images.slide has no properties
Source File: Line: 95
I am just a newbie to javascripts and have very recently recognised the potential power of them . I would be very greatfull if someone could please help me fix this error as i can feel it that the code is not too far from what it's meant to accomplish as i have managed to read of my xml file and display the content as an html table and i have manged to display and animation based on some passign in some pictures' url and links as array to my functions. Any help would be very highly appreciated .
<script type="text/javascript" language="javascript" >
// JScript File
var xmlDoc ;
var slideimages=new Array(10);
var slidelinks=new Array(10);
var slideshowspeed=2000
var whichlink=0
var whichimage=0
function importXML()
{ alert('inside importXML 1');
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = createTable;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4) createTable()
};
}
else
{
alert('Your browser can\'t handle this script');
return;
}
xmlDoc.load("Top_Animation.xml");
}
function createTable()
{
var x = xmlDoc.getElementsByTagName('Image');
for (i=0;i<x.length;i++)
{
for (j=0;j<x.childNodes.length;j++)
{
if (x.childNodes[j].nodeType != 1) continue;
if (j=0)
{
document.images.item['slide']= x.childNodes[j].firstChild.nodeValue
slideshowimages(x.childNodes[j].firstChild.nodeValue);
}
if (j=1)
{
slideshowlinks(x.childNodes[j].firstChild.nodeValue);
}
}
}
}
function gotoshow()
{ importXML();
if (!window.winslide||winslide.closed)
winslide=window.open(slidelinks[whichlink])
else
winslide.location=slidelinks[whichlink]
winslide.focus()
}
function slideshowimages()
{
for (i=0;i<slideshowimages.arguments.length;i++)
{
slideimages=new Image()
slideimages.src=slideshowimages.arguments
}
}
function slideshowlinks()
{
for (i=0;i<slideshowlinks.arguments.length;i++)
slidelinks=slideshowlinks.arguments
}
function slideit()
{
if (!document.images)
return
document.images.slide.src=slideimages[whichimage].src
whichlink=whichimage
if (whichimage<slideimages.length-1)
whichimage++
else
whichimage=0
setTimeout("slideit()",slideshowspeed)
}
slideit()
</script>
<body >
<a href="javascript:gotoshow();"><img alt="animated banner" src=" id="slide"/></a>
My xml file looks like
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="Top_Animation.xsl"?>
<Images xmlns:xsi="xsi:schemaLocation=" <Image>
<URL>
</URL>
<Link>
</Link>
</Image>
<Image>
<URL>
</URL>
<Link>
</Link>
</Image>
<Image>
<URL>
</URL>
<Link>
</Link>
</Image>
<Image>
<URL>
</URL>
<Link>
</Link>
</Image>
<Image>
<URL>
</URL>
<Link>
</Link>
</Image>
</Images>
my xss file looks like
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Images" xmlns="" xmlns:xs=" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Images" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Image">
<xs:complexType>
<xs:sequence>
<xs:element name="URL" type="xs:string" minOccurs="0" />
<xs:element name="Link" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
My xsl file looks something like this
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="
<xsl:template match="/">
<html>
<body>
<!--
This is an XSLT template file. Fill in this area with the
XSL elements which will transform your XML to XHTML.
-->
<h2>My Images</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">URL</th>
<th align="left">Link</th>
</tr>
<xsl:for-each select="Images/Image">
<tr>
<td>
<xsl:value-of select="URL"/>
</td>
<td>
<xsl:value-of select="Link"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Thanxs in advance !