Solved

Google Chrome - Javascript Problem

Posted on 2008-10-10
20
4,974 Views
Last Modified: 2008-12-18
Hello Experts,

Having a little trouble with Google Chrome and some bit of my JavaScript. The snippet below woks fine in IE 7 but not in Chrome. Could someone please advise why it wouldn't? And a solution to the problem.

All it does is hide a green tick when the user selects a different name, very simple stuff... supposedly.

Thanks in advance.
function switchName(strName,strEmp){
		var oldName = parent.document.getElementById('tempName').value.replace(' ','');
		document.getElementById('IMG'+oldName).innerHTML = '';
		document.getElementById('IMG'+strName.replace(' ','')).innerHTML = '<img src="../../content/images/green_tick.gif" width="16" height="16">';
		
		if(strName == 'CUSTOM'){
			parent.document.getElementById('tempName').value = document.getElementById('customName').value;
			parent.document.getElementById('tempEmployer').value = document.getElementById('customEmployer').value;
		}else{
			parent.document.getElementById('tempName').value = strName;
			parent.document.getElementById('tempEmployer').value = strEmp;
		}
	}

Open in new window

0
Comment
Question by:davecestria
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 10
20 Comments
 
LVL 6

Author Comment

by:davecestria
ID: 22685298
Just to mention the code snippet is used in an IFRAME.
0
 
LVL 5

Expert Comment

by:mverschoof
ID: 22685504
Doesn't the following code insert the <img src...> into another <img> tag?

Do you have a test file or something to show the problem?
document.getElementById('IMG'+strName.replace(' ','')).innerHTML = '<img src="../../content/images/green_tick.gif" width="16" height="16">';

Open in new window

0
 
LVL 6

Author Comment

by:davecestria
ID: 22685525
IMG is the start of a span tag.

for example;

<span id="IMGDaveCestria">
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
LVL 5

Expert Comment

by:mverschoof
ID: 22685543
Oh, that makes a lot of sense. Still trying to figure out why CHrome won't support it.

Do Firefox, Opera and Safari work properly?
0
 
LVL 6

Author Comment

by:davecestria
ID: 22685554
Hello,

Firefox doesn't!

It's for an internal part of the system... so only IE and Chrome support is required.
0
 
LVL 5

Expert Comment

by:mverschoof
ID: 22685594
Ok but Chrome is a lot like FireFox so if it worked in FF it would be a lot more difficult.

If there is a file i could use to test that would be great. I have some developer tools to check your javascript so if you have something online it would make things a lot easier and quicker
0
 
LVL 6

Author Comment

by:davecestria
ID: 22685649
I would prefer not to post the address on a public site... could you please send me an email and i will reply with the address;

dave at cestriadistribution.com

Cheers :o)
0
 
LVL 5

Expert Comment

by:mverschoof
ID: 22685949
I'm sorry, but i don't have any problems here. Everything seems to work.

Don't know what else to tell you
0
 
LVL 6

Author Comment

by:davecestria
ID: 22685959
So when you cick on a vehicle, a modal message opens up, then when you click on a different entry in the list, the green tick appaers next to the clicked entry?
0
 
LVL 5

Accepted Solution

by:
mverschoof earned 500 total points
ID: 22686040
Might have just been in IE. Now the error appears in FireFox.

parent.document.getElementById("tempVehicleReg") is null

That is your problem. It is possible the element isn't found, or that the element isn't declared before you call to it
0
 
LVL 6

Author Comment

by:davecestria
ID: 22686075
Strange... tempVehicleReg is deinately there., any suggestions?
0
 
LVL 5

Expert Comment

by:mverschoof
ID: 22686150
is the javascript executed before tempVehicleReg is loaded? Sure there are no type-o's?
0
 
LVL 6

Author Comment

by:davecestria
ID: 22686167
It all works fine in IE, i think that covers the typo's possibility no?
0
 
LVL 5

Expert Comment

by:mverschoof
ID: 22686205
That's true. But this type of problem usually occurs when javascript calls a non-existing or non declared element. So the element may not exist when you run the script. This often works differently in IE and non-IE explaining the difference
0
 
LVL 6

Author Comment

by:davecestria
ID: 22686211
Maybe there is a different way of addressing an element in the parent frame? I'm googling but not finding much.
0
 
LVL 5

Expert Comment

by:mverschoof
ID: 22686312
Maybe Chrome doesn't support the replace in the string. Don't know what else it could be
0
 
LVL 6

Author Comment

by:davecestria
ID: 22686336
Not the replace string...
0
 
LVL 5

Expert Comment

by:mverschoof
ID: 22686639
Then i'm running out of options... i will search around but don't have any more time today.

Probably this weekend
0
 
LVL 6

Author Comment

by:davecestria
ID: 22686698
Hmmm, something as simple as this is causing the same error without even using IFRAMES;
function gV(idToRetrieve){
      return document.getElementById(idToRetrieve).value;
}
alert(gV('Mate5355'));

I HATE GOOGLE & FIREFOX

0
 
LVL 5

Expert Comment

by:mverschoof
ID: 22686740
where have you placed your element and where is the call to the function?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question