Jump to content

Javascript problem in IE


ATM

Recommended Posts

Hello,I'm using two pages one xml and one xsl, I just though I would mention it as that might be something to do with the problem, but I highly doubt it.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	<xsl:template match="/"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>******</title><style type="text/css">div.active {display:block;}div.back {border-bottom-color:#CCCCCC;border-bottom-style:solid;border-bottom-width:1px;color:#333333;cursor:pointer;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;font-weight:700;height:25px;line-height:25px;overflow:hidden;padding-left:20px;width:100%;}div.banner {border-bottom-color:#CCCCCC;border-bottom-style:solid;border-bottom-width:1px;height:100px;width:100%;}div.content {border-bottom-color:#CCCCCC;border-bottom-style:solid;border-bottom-width:1px;height:440px;width:100%;}div.feature {color:#333333;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;margin-left:10px;padding:5px;width:100%;}div.footer {height:30px;width:100%;}div.hidden {display:none;}div.information {background-color:#FFFFFF;border-color:#CCCCCC;border-style:solid;border-width:1px;height:400px;margin-left:240px;margin-top:20px;overflow-x:hidden;overflow-y:auto;position:absolute;width:440px;}div.item {border-bottom-color:#CCCCCC;border-bottom-style:solid;border-bottom-width:1px;color:#333333;cursor:pointer;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;height:25px;line-height:25px;overflow:hidden;padding-left:20px;width:100%;}div.logo {border-bottom-color:#CCCCCC;border-bottom-style:solid;border-bottom-width:1px;height:100px;width:100%;}div.menu {border-bottom-color:#CCCCCC;border-bottom-style:solid;border-bottom-width:1px;height:30px;width:100%;}div.navigation {background-color:#FFFFFF;border-color:#CCCCCC;border-style:solid;border-width:1px;height:400px;margin-left:20px;margin-top:20px;overflow:hidden;position:absolute;width:200px;}div.page {background-color:#FFFFFF;border-color:#CCCCCC;border-style:solid;border-width:1px;height:auto;margin-left:auto;margin-right:auto;width:700px;}div.title {border-bottom-color:#CCCCCC;border-bottom-style:solid;border-bottom-width:1px;color:#333333;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;font-weight:700;height:25px;line-height:25px;overflow:hidden;padding-left:20px;width:100%;}</style><script type="text/javascript"><![CDATA[function hide(product){	var elements = document.getElementsByTagName('div');		for (var i = 0; i < elements.length; i++)		{				if (elements[i].className == 'active')			{				elements[i].className='hidden';			}			}			document.getElementById(product).className='active';}]]></script></head><body><div class="page">	<div class="logo">		</div>		<div class="menu">		</div>		<div class="banner">		</div>		<div class="content">			<div class="navigation">					<div id="categories">						<div class="title">									Categories								</div>							<xsl:for-each select="root/category">					<xsl:variable name="category" select="@name" />									<div class="item" onclick="document.getElementById('{$category}').style.display='block';document.getElementById('categories').style.display='none';">											<xsl:value-of select="@name"/>										</div>								</xsl:for-each>								</div>						<xsl:for-each select="root/category">							<xsl:variable name="category" select="@name" />							<div class="hidden" id="{$category}">							<div class="title">											<xsl:value-of select="@name"/>										</div>										<xsl:for-each select="manufacturer">											<xsl:variable name="manufacturer" select="@name" />											<div class="item" onclick="document.getElementById('{$category}/{$manufacturer}').style.display='block';document.getElementById('{$category}').style.display='none';">													<xsl:value-of select="@name"/>												</div>										</xsl:for-each>									<div class="back" onclick="document.getElementById('{$category}').style.display='none';document.getElementById('categories').style.display='block';">											Back										</div>								</div>							</xsl:for-each>						<xsl:for-each select="root/category">							<xsl:variable name="category" select="@name" />								<xsl:for-each select="manufacturer">									<xsl:variable name="manufacturer" select="@name" />										<div class="hidden" id="{$category}/{$manufacturer}">											<div class="title">												<xsl:value-of select="@name"/>											</div>												<xsl:for-each select="product">													<xsl:variable name="product" select="@name" />													<div class="item" onclick="hide('{$product}');">															<xsl:value-of select="@name"/>														</div>												</xsl:for-each>												<div class="back" onclick="document.getElementById('{$category}/{$manufacturer}').style.display='none';document.getElementById('{$category}').style.display='block';">													Back												</div> 										</div>						</xsl:for-each>							</xsl:for-each>				</div>				<div class="information">					<xsl:for-each select="root/category/manufacturer/product">							<xsl:variable name="name" select="@name" />								<xsl:variable name="image" select="image" />							<div class="hidden" id="{$name}">									<div class="title">											<xsl:value-of select="@name" />										</div>										<xsl:for-each select="feature">											<div class="feature">													<xsl:value-of select="@information" />												</div>										</xsl:for-each>								</div>						</xsl:for-each>				</div>		</div>		<div class="footer">		</div></div></body></html></xsl:template></xsl:stylesheet>

<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="products.xsl"?><root>	<category name="Camcorders">			<manufacturer name="Canon">					<product name="Elura 100">							<model>Elura 100</model>							<image>media/graphics/Elura-100.jpg</image>										<feature information="Widescreen HR Recording"></feature>							<feature information="Optical Performance You Can See"></feature>							<feature information="Brilliant Video"></feature>							<feature information="Stunning Digital Photography"></feature>							<feature information="Perfect Exposures"></feature>							<feature information="Share Your Video"></feature>							<feature information="Share Your Photos"></feature>						</product>		</manufacturer>				<manufacturer name="JVC">					<product name="Everio GZ-MC500">						<model>Everio GZ-MC500</model>								<image>media/graphics/Everio-GZ-MC500.jpg</image>								<feature information="Microdrive format lets you shoot up to 60 minutes of high-quality MPEG-2 video"></feature>								<feature information="10x optical zoom"></feature>								<feature information="1.8-inch LCD monitor"></feature>								<feature information="Create and share DVDs easily with included software"></feature>											</product>				</manufacturer>				<manufacturer name="Panasonic">					<product name="AG-HVX200">						<model>AG-HVX200</model>								<image>media/graphics/AG-HVX200.jpg</image>								<feature information="Camcorder Type Digital"></feature>								<feature information="Recording Format Mini DV"></feature>								<feature information="Recording System NTSC / PAL"></feature>								<feature information="CCD Quantity 3"></feature>								<feature information="Optical Zoom 13x"></feature>											</product>				</manufacturer>				<manufacturer name="Sony">					<product name="DCR-DVD408">						<model>DCR-DVD408</model>								<image>media/graphics/DCR-DVD408.jpg</image>								<feature information="2.1-megapixel ClearVid CMOS sensor"></feature>								<feature information="Carl Zeiss Vario- Sonnar T* lens; 10x optical/80x digital zoom"></feature>								<feature information="Dolby Digital 5.1-channel recording; built-in microphone"></feature>								<feature information="2.7-inch widescreen touch-panel Clear Photo plus LCD"></feature>								<feature information="DVD-R/RW/+RW/+R DL compatible"></feature>											</product>				</manufacturer>		</category>	<category name="Car Electronics & GPS">				<manufacturer name="Alpine">				</manufacturer>				<manufacturer name="Clarion">				</manufacturer>				<manufacturer name="Garmin">				</manufacturer>				<manufacturer name="Kenwood">				</manufacturer>				<manufacturer name="Pioneer">				</manufacturer>				<manufacturer name="TomTom">				</manufacturer>			</category>		<category name="Cell Phones & PDA">				<manufacturer name="LG">				</manufacturer>				<manufacturer name="Motorola">				</manufacturer>			<manufacturer name="Nokia">				</manufacturer>				<manufacturer name="PDA">				</manufacturer>				<manufacturer name="Sony Ericsson">				</manufacturer>		</category>		<category name="Digital Cameras">			<manufacturer name="Canon">				</manufacturer>				<manufacturer name="Nikon">				</manufacturer>				<manufacturer name="Olympus">				</manufacturer>				<manufacturer name="Panasonic">				</manufacturer>				<manufacturer name="Sony">				</manufacturer>		</category>		<category name="LCD/Plasma TV">			<manufacturer name="Fujitsu">				</manufacturer>				<manufacturer name="Panasonic">				</manufacturer>				<manufacturer name="Pioneer">				</manufacturer>				<manufacturer name="Samsung">				</manufacturer>				<manufacturer name="Sony">				</manufacturer>				<manufacturer name="Toshiba">				</manufacturer>		</category>		<category name="Multimedia Players">			<manufacturer name="Apple">				</manufacturer>				<manufacturer name="DVD players">				</manufacturer>				<manufacturer name="Other">				</manufacturer>		</category>		<category name="Notebooks/Laptops">			<manufacturer name="Apple">				</manufacturer>				<manufacturer name="Hewlett Packard">				</manufacturer>				<manufacturer name="Sony">				</manufacturer>				<manufacturer name="Toshiba">				</manufacturer>				<manufacturer name="Acer">				</manufacturer>		</category>		<category name="Video Games">			<manufacturer name="Microsoft">				</manufacturer>				<manufacturer name="Nintendo">				</manufacturer>				<manufacturer name="Sony">				</manufacturer>		</category>	</root>

Below is the javascript.

<script type="text/javascript"><![CDATA[function hide(product){	var elements = document.getElementsByTagName('div');		for (var i = 0; i < elements.length; i++)		{				if (elements[i].className == 'active')			{				elements[i].className='hidden';			}			}			document.getElementById(product).className='active';}]]></script>

This is what calls the function:<div class="item" onclick="hide('{$product}');">IE returns two errors; once the page has loaded it says expected ')' and on clicking a product which triggers the hide function, it says object expected.Sorry for the long code but I have spent many hours on this.Thank you.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...