...

View Full Version : Chrome issue while calling Js function defined in html file



htmlster
07-28-2011, 03:38 AM
Hi,


I'm trying to call a Js function from a test.js located in a HTML file.

I'm getting error message "Object has no method..." in Chrome. But no issues are seen in Firefox. Can any one please let me know how i can fix this.

<html>
<head>
....
....
....
<div>
<html>
<head>
<script src="test.js"></script>
<script>
function aFunc()
{
alert ("Inside aFunc");
}
</script>
</head>
<body>
</html>
....
....
....
</div>
</head>
</html>

test.js

function bFunc ()
{
aFunc ();
}

devnull69
07-28-2011, 06:33 AM
I'm trying to call a Js function from a test.js located in a HTML file.


<html>
<head>
....
....
....
<div>
<html>
<head>
<script src="test.js"></script>
<script>
function aFunc()
{
alert ("Inside aFunc");
}
</script>
</head>
<body>
</html>
....
....
....
</div>
</head>
</html>

test.js


function bFunc ()
{
aFunc ();
}



Questions:

1. You are not calling ANY function in this piece of code you are showing. Where is the function call you are talking about?
2. Your HTML is totally messy ... it has opening and closing tags all over the place, mostly where they don't belong. Is this your actual code or some kind of "mass typo"?

htmlster
07-28-2011, 03:10 PM
If you observe closely there is an html document within a div. There are two html tags in the overall file when you view in browser. I'm calling aFunc from bFunc defined in test.js.

Assume that bFunc is getting called when some external event is triggered.

DaveyErwin
07-28-2011, 03:31 PM
Assume that bFunc is getting called when some external event is triggered.

No don't assume that bFunc is being called.
Put an alert in bFunc to be sure.
The code you have posted works
for me when bFunc is called like this.


<html>
<head>
....
....
....
<div>
<html>
<head>
<script src="test.js"></script>
<script>
function aFunc()
{
alert ("Inside aFunc");
}

bFunc();

</script>
</head>
<body>
</html>
....
....
....
</div>
</head>
</html>

maybe your problem is somewhere else



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum