Hi All,
I'm seeing a strange issue with my code below. The content received thru the xmlHttpRequest, is not being displayed in IE8, after clicking the link. It is displayed only after moving the mouse/cursor, after clicking the link. Anyone sees what could be the problem here ? Please help. -
<html>
-
<head>
-
<script type="text/javascript">
-
-
var xmlHttpfunction;
-
function ShowHint(id)
-
{
-
xmlHttp = GetXmlHttpObject();
-
-
if (xmlHttp == null)
-
{
-
alert ("Browser does not support HTTP Request");
-
return;
-
}
-
-
var url = "myurl.php";
-
url = url+"?id="+id;
-
xmlHttp.onreadystatechange = stateChanged;
-
xmlHttp.open("GET",url,true);
-
xmlHttp.send(null);
-
}
-
-
function stateChanged()
-
{
-
if (xmlHttp.readyState === 4)
-
{
-
document.getElementById("elementRight").style.display = "block";
-
document.getElementById("elementRight").innerHTML = xmlHttp.responseText;
-
}
-
}
-
-
</script>
-
</head>
-
<body>
-
<div id="elementLeft">
-
<ul >
-
<li>
-
<a href="#" onclick="ShowHint("1");"> Item1 </a>
-
</li>
-
<li>
-
<a href="#" onclick="ShowHint("2");"> Item1 </a>
-
</li>
-
<li>
-
<a href="#" onclick="ShowHint("3");"> Item1 </a>
-
</li>
-
</ul>
-
</div>
-
<div class="element" id="elementRight">
-
</div>
-
</body>
-
</html>
-
The css for 'element' is - -
.element {
-
overflow:hidden;
-
border:1px;
-
border:#7CAFBE solid 1px;
-
height:50%;
-
width:79%;
-
float:right;
-
padding:0 0 0 10px;
-
padding-left:1px;
-
z-index:1000;
-
}
-
Many Thanks,
csoft
3 2209 Oralloy 988
Recognized Expert Contributor
csoft,
I am surprised that you're seeing anything at all, considering the apparent syntax errors in lines 38, 41, and 44, where you have apparently violated HTMLs quoting rules. For example: - <a href="#" onclick="ShowHint("1");"> Item1 </a>,
Should probably be: - <a href="#" onclick="ShowHint('1');"> Item1 </a>,
Nevertheless, since it is working, that is not the fundamental problem that you're encountering...
The second problem I see is that you aren't stopping the anchor link in your code snippet. You probably should add a return false; to each of the events, like this: - <a href="#" onclick="ShowHint('1'); return false;"> Item1 </a>,
Luck!
Oralloy
Oralloy,
Thanks for responding.
This was a typo, while copying the code - -
<a href="#" onclick="ShowHint("1");"> Item1 </a>
-
Sorry about that.
I now have the following, as you suggested - -
<a href="#" onclick="ShowHint('1');return false;">
-
Item1
-
</a>
-
But, I still see the same result.
Actually, when I click on the link 'Item1', a dotted border around 'Item1' appears and only when I move the mouse arrow out of this dotted border, the content is loaded. Has this got anything to do with the anchor tag itself ? The following is the css for the anchor tag - -
a {
-
color:#000000;
-
text-decoration: none;
-
font-family: verdana;
-
font-size: 11px;
-
padding:0 0 0 10px;
-
text-align: center;
-
cursor: pointer;
-
}
-
Thanks Again,
csoft
Oralloy 988
Recognized Expert Contributor
You may be running into variable scoping rules with xmlHttp.
Try hoisting the onreadystatecha nge to an anonymous function, like this: - function ShowHint(id)
-
{
-
xmlHttp = GetXmlHttpObject();
-
-
if (xmlHttp == null)
-
{
-
alert ("Browser does not support HTTP Request");
-
return;
-
}
-
-
var url = "myurl.php";
-
url = url+"?id="+id;
-
xmlHttp.onreadystatechange =
-
function(){
-
if (xmlHttp.readyState == 4)
-
{
-
document.getElementById("elementRight").style.display = "block";
-
document.getElementById("elementRight").innerHTML = xmlHttp.responseText;
-
}
-
}
-
xmlHttp.open("GET",url,true);
-
xmlHttp.send(null);
-
}
Also, I changed the state comparison from absolute equality (===) to simple equality (==).
Luck!
Oralloy
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Stewart |
last post by:
Hi Experts.
Please put the code sample below into an html document and take a look
at in NN6+. One span should be shown while the other is hidden.
Clicking the button should reverse this. However it doesn't.
Removing the table structure from around the text fixes it, but I need
the table structure (this is very simplified example).
Hope someone can provide an alternative?
|
by: PaulB |
last post by:
Good Morning everybody,
I'm trying to adapt a tutorial script that will handle the behaviour of an
"Expanding/Contracting" site-navigation menu. The code that seems to
handle the expansion and contraction follows at the bottom of my
message here.
This following line is a big part of my hang-up:
document.getElementById('m1').style.display='none';
|
by: Jake Barnes |
last post by:
Imagine I've this block of HTML:
<p>Alex Schein Mailing List <input type="checkbox"
name="newslettersToUse" value="133156"> (<a href="mcControlPanel.php"
onClick="hideOrShowDivById('emailList133156'); return false;">See
emails?</a>)</p>
<form method="post" action="mcControlPanel.php"
id="emailList133156" style="display:none;"><textarea
name="formInputs">nazjeehaj@son.org,
|
by: RonY |
last post by:
I have a dropdown which calls SetTimePeriod method on change the selection. In the JS function, I reset the field style.display based on what the selection is. This works fine with IE but not working with Firefox browser.
The firefox browser has problem to display a field after its style.display is reset. At the end of the JS function, I printed out the fields style.display value. They are set correctly. How to resovle this?
My JS is :
...
|
by: Winston |
last post by:
Where is the mistake?
I want to make a simple menu. These are two pieces of two files...
function ShowMenu(objeto) {
is_open = document.getElementById(objeto).style.display;
document.getElementById("menu_p").style.display='none';
if (is_open == 'none') {
document.getElementById(objeto).style.display='block';
}
| |
by: mandarchalke29 |
last post by:
Can you please tell me that document.getElementById("").style.display="Inline" what does this statement will do.
|
by: omerbutt |
last post by:
hi there i am amking an inventory application with php,ajax,javascript,html,dhtml,sql
the problem is that i have hidden the input fields regarding the replace no's of the parts with this line of code
document.getElementById('bgrp1').style.visibility='hidden';
document.getElementById('lable_rp_no1').style.display='none';
document.getElementById('rp_no1').style.display='hidden';
the code for the html part is here
|
by: jmatos |
last post by:
I need to change the style of an element changing its padding-left property (got it in firefox but IE is a different battle..). I can use document.getElementById().style.XX
to everything i need, except with padding-left, as it is separated by a ' - ' and it is not correct to use it as it was supposed to:
document.getElementById('el').style.padding-left = '5px'
will throw 'invalid assignment left-hand side', as expected..
Any help...
|
by: dgourd |
last post by:
I cant get the style.display property to work properly. I have this test html page:
<!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=utf-8" />
<title>Test Javascript</title>
<script language="javascript" type="text/javascript">
...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |