...

View Full Version : Not well-formed..



johay
05-07-2007, 10:55 AM
I'm doing, some cross-browsering, scripting, to my site. I'm preety new to javascript. So making alot of mistakes.
I went to open the file in mozilla firefox and got:
Error: not well-formed
Source File: file:///.......
Line: 14, Column: 27
Source Code:
for (i=0; i<frm.length; i++) {--------------------------^

In the 'error console' Like I said I'm new to javascript. So I really don't know too much about this error. What could be causeing this problem?

liorean
05-07-2007, 11:32 AM
Is this in an XML document? (I would guess it is from the error.)

If so, the problem is that scripts in XML must either be wrapped in CDATA blocks or be in external files if containing the characters < or & since those have special meaning in XML.


However, give us a link to the actual document or if it's small, post it in it's entirety here - that way we can examine it ourselves.

johay
05-08-2007, 12:08 PM
<html>
<head>
<title> *** TMN Script Watcher *** </title>
<LINK href="http://www.themafianetwork.net/myStyle.css" type="text/css" rel="stylesheet">
<script language="JavaScript" src="clientSideInclude.js">
</script>
<script language="JavaScript" src="findInPage.js">
</script>
<script name="count" type="text/javascript">
function count1() {
return findInPage('name1');
}
function count2()
{
return findInPage('name2');
}
function count3()
{
return findInPage('name3');
}
function count4()
{
return findInPage('name4');
}
function count5()
{
return findInPage('name5');
}
function count6()
{
return findInPage('name6');
}
function count7()
{
return findInPage('name7');
}
</script>
<script language="JavaScript">
if (document.images)
setTimeout('location.reload(true)',1000*30); // forces a reload from the server
else
setTimeout('location.href = location.href',1000*30); // just reloads the page
</script>

</head>
<body onLoad="clientSideInclude('includeone', 'http://www.example.com/mail.aspx');">
<span id="includeone">
</span>

<form name="search">
<font size=3><input name="string" type="text" size=15 onChange="numtimes = 0;"></font>
<input type="button" value="Find" onclick="return findInPage(document.search.string.value);">
<img onLoad="mytime=setTimeout('count1(3)',3000)" src="http://www.yezz.no/img/number1.gif">
<img onLoad="mytime=setTimeout('count2(3)',3000)" src="http://www.yezz.no/img/number2.gif">
<img onLoad="mytime=setTimeout('count3(3)',3000)" src="http://www.yezz.no/img/number3.gif">
<img onLoad="mytime=setTimeout('count4(3)',3000)" src="http://www.yezz.no/img/number4.gif">
<img onLoad="mytime=setTimeout('count5(3)',3000)" src="http://www.yezz.no/img/number5.gif">
<img onLoad="mytime=setTimeout('count6(3)',3000)" src="http://www.yezz.no/img/number6.gif">
<img onLoad="mytime=setTimeout('count7(3)',3000)" src="http://www.yezz.no/img/number7.gif">

</form>
</body>
</html>




That's it there. Not long at all.

liorean
05-08-2007, 12:24 PM
The code your error lies in is not included in that code snippet. You need to show us the external JavaScript files too. Currently if just gives the following errors when tried:

clientSideInclude is not defined
onload(load )
cf%20thread%20113... (line 1)
<html>
cf%20thread%20113... (line 1)


findInPage is not defined
count2()
cf%20thread%20113... (line 15)
return findInPage('name1');
cf%20thread%20113... (line 11)


findInPage is not defined
return findInPage('name2');
cf%20thread%20113... (line 15)

etc...

johay
05-08-2007, 12:29 PM
The code your error lies in is not included in that code snippet. You need to show us the external JavaScript files too. Currently if just gives the following errors when tried:

clientSideInclude is not defined
onload(load )
cf%20thread%20113... (line 1)
<html>
cf%20thread%20113... (line 1)


findInPage is not defined
count2()
cf%20thread%20113... (line 15)
return findInPage('name1');
cf%20thread%20113... (line 11)


findInPage is not defined
return findInPage('name2');
cf%20thread%20113... (line 15)

etc...

Ahh I see

Well, The findinpage.js is:

var numtimes = 0;

function findInPage(str) {

if (str == "") return false;

if (document.layers) {
if (!window.find(str)) {
while(window.find(str, false, true)) n++;
}
else numtimes++;

if (numtimes == 0) alert("The word \""+ str +"\" was not found on this page.");
}

if (document.all) {
var txt = window.document.body.createTextRange();
var found = txt.findText(str);

for (var i = 0; i <= numtimes && found != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}

if (found) {
window.location="http://www.example.com/userlogin.php?act=out";
}

else { window.status='Script status: Okay';
}
return false;
}
}

Clientsideinclude:

function clientSideInclude(id, url) {
var req = false;
// For Safari, Firefox, and other non-MS browsers
if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch (e) {
req = false;
}
} else if (window.ActiveXObject) {
// For Internet Explorer on Windows
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
req = false;
}
}
}
var element = document.getElementById(id);
if (!element) {
alert("Bad id " + id +
"passed to clientSideInclude." +
"You need a div or span element " +
"with this id in your page.");
return;
}
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', url, false);
req.send(null);
element.innerHTML = req.responseText;
} else {
element.innerHTML =
"Sorry, your browser does not support " +
"XMLHTTPRequest objects. This page requires " +
"Internet Explorer 5 or better for Windows, " +
"or Firefox for any system, or Safari. Other " +
"compatible browsers may also exist.";
}
}

function init() {

if (window.XMLHttpRequest) sforceClient.appType = Sforce.Application.Type.FireFox;

}
Sorry, I coudnt link you to any site, But, i use this code on my actully computer. Like "File:///Blah blah.."



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum