Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Not well-formed..

    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?

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <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.

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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:
    Code:
    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...
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #5
    New Coder
    Join Date
    May 2006
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by liorean View Post
    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:
    Code:
    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:
    Code:
    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:
    Code:
    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.."


  •  

    LinkBacks (?)

    1. 04-05-2014, 12:34 PM

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •