I've try to figure it since 3 days a go..:-( and sorry for my english.
what i want to do is displaying a random link on my conduit toolbar and it change randomly everytime EBNavigateComplete event occur. EBNavigateComplete is just one of conduit's event.
It works fine on my firefox but the random link never change when i use IE. I know i hate IE but i want to give support to my member who use this....please help me find what wrong with my code below.
I've try it on 3 different PC with IE and all the same, the problem is not on the local IE setting.
The problem is NOT between IE and EBNavigateComplete but something wrong specifically on my code below.
I've try to search a lot forum out there and I think the problem is related to ajax function, innerHTML, responseText on IE.
i'm not really advance on php, ajax and javascript, i really apreciate if anyone can look to my code and find what's wrong about it and please explain in detail...thanks a lot before.
the code in the HTML component of my toolbar:
<html>
<head>
<script type="text/javascript" src="http://www.conduit.com/api/BrowserCompApi.aspx"></script>
<script type="text/javascript">
var http = '';
function createRequestObject() {
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
} else {
ro = new XMLHttpRequest();
}
return ro;
}
function handleResponse() {
if(http.readyState == 4){
get_id('ad_div').innerHTML = http.responseText;
get_id('ad_div').style.display = 'block';
}
}
function EBNavigateComplete() {
setTimeout(do_ajax_call,100);
}
function do_ajax_call() {
http = createRequestObject();
http.open('get', 'http://mysite.com/randomlink_dev.php');
http.onreadystatechange = handleResponse;
http.send(null);
}
function get_id(id) {
if (document.getElementById) {
return document.getElementById(id);
} else {
return document.all[id];
}
}
</script>
</head>
<body onload="EBNavigateComplete();" style="margin-top:0;">
<table width=100% cellpadding=0 cellspacing=0 height=26>
<tr>
<td>
<span id="ad_div" style="display: none;"></span>
</td>
</tr>
</table>
</body>
</html>
the simple random link code that being called: http://mysite.com/randomlink_dev.php
<?
$colorset = array(1,2,3);
srand(time());
$random = (rand()%3);
if ($colorset[$random] == 1)
{
$rowcolor = "#FFFFCC";
$fontcolor = "#0066A7";
$fontbgcolor = "#FFFFCC";
}
if ($colorset[$random] == 2)
{
$rowcolor = "#000000";
$fontcolor = "#FFFFFF";
$fontbgcolor = "#000000";
}
if ($colorset[$random] == 3)
{
$rowcolor = "#DD0000";
$fontcolor = "#000000";
$fontbgcolor = "#FFFFFF";
}
//set the urls
$urls = array("http://google.com" ,"http://hotmail.com" ,"http://hawkee.com" );
//set the text links
$text = array("Google" ,"Hotmail" ,"Hawkee");
srand(time());
//set the number in (rand()%3); for however many links there are
$random = (rand()%3);
echo ("<table width=100% cellpadding=0 cellspacing=0 height=26><tr><td align=center style=\"background-color:$rowcolor;\"><a style=\"font-family:verdana,arial; font-size:10px; color:$fontcolor; background-color:$fontbgcolor; text-decoration:underline; \" href=\"$urls[$random]\" target=_blank>$text[$random][/url]</td></tr></table>");
?>