unclhos
05-31-2009, 04:01 AM
I must start with I am very new with javascript. I know what I can find basically. :D But this site I am working on works on both Firefox and Chrome. But It will not work on IE and don't know why. Here is what I have:
Main Page
<td valign="top" width="40%">
<span id="gearInfo" name="gearInfo">
</span></td>
Iframe inside Main Page
<script src="showgear.js" type="text/javascript"></script>
<div class="gearitem">
<button value="<?php echo $row['type'];?>" onclick="showGear(this.value)">
<img class="thumbnail" src="images/<?php echo $row['image'];?>">
</button>
</div>
Here is a populated copy of the above code:
<div class="gearitem">
<button value="Backpack" onclick="showGear(this.value)">
<img class="thumbnail" src="images/palisade80_backpack.gif">
</button>
</div>
Here is the script:
var xmlHttp
function showGear(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="getgear.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
parent.document.getElementById('gearInfo').innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
Main Page
<td valign="top" width="40%">
<span id="gearInfo" name="gearInfo">
</span></td>
Iframe inside Main Page
<script src="showgear.js" type="text/javascript"></script>
<div class="gearitem">
<button value="<?php echo $row['type'];?>" onclick="showGear(this.value)">
<img class="thumbnail" src="images/<?php echo $row['image'];?>">
</button>
</div>
Here is a populated copy of the above code:
<div class="gearitem">
<button value="Backpack" onclick="showGear(this.value)">
<img class="thumbnail" src="images/palisade80_backpack.gif">
</button>
</div>
Here is the script:
var xmlHttp
function showGear(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="getgear.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
parent.document.getElementById('gearInfo').innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}