From: Joe Nine on 2 Jun 2010 15:00 I had a big page and I was getting an error. To make it easier to show here and recreate I trimmed and trimmed until there was almost nothing left but the error remains. On IE8 and Opera 10 I get no errors. On Firefox 3.5, Safari 4 and Chrome 4 I get a different error on each. Here's the entire html page. As you'll see I've removed tags and attributes that weren't relevant to the problem so it's an absolute bare minimum. <html> <body> <script> document.write("<scr"+"ipt src=''><\/scr"+"ipt>"); </script> </body> </html> Earlier it had a head section, the script tags had type on them and there was a src URL for the script but none of that had anything to do with the error so I left it out. On XP/Firefox 3.5 I get: "invalid XML tag syntax" with an error pointing to the first plus symbol. On XP/Safari 4 I get: "Syntax Error: Parse Error" On XP/Chrome 4 I get: "Uncaught SyntaxError: Unexpected token <" In an earlier version, I had an extra line of code before the document.write: var abc;if(true){abc=true;} When that's in (and remember that's trimmed and trimmed from what it originally was, which wasn't just if(true)) instead of the errors mentioned, I get a different error in Firefox. Instead I get "missing } in XML expression" with an arrow pointing to the semi-colon after abc=true
From: Scott Sauyet on 2 Jun 2010 15:16 On Jun 2, 3:00 pm, Joe Nine <j...(a)yahoo.com> wrote: > <html> > <body> > <script> > document.write("<scr"+"ipt src=''><\/scr"+"ipt>"); > </script> > </body> > </html> I think the error is because of the empty src attribute in the generated SCRIPT element. It's requesting the current document as the source of the script element, and when it finds HTML instead of Javascript, it chokes. If you said "src='abc'" does the error disappear? -- Scott
From: Joe Nine on 2 Jun 2010 15:23 Scott Sauyet wrote: > On Jun 2, 3:00 pm, Joe Nine <j...(a)yahoo.com> wrote: >> <html> >> <body> >> <script> >> document.write("<scr"+"ipt src=''><\/scr"+"ipt>"); >> </script> >> </body> >> </html> > > I think the error is because of the empty src attribute in the > generated SCRIPT element. > > It's requesting the current document as the source of the script > element, and when it finds HTML instead of Javascript, it chokes. If > you said "src='abc'" does the error disappear? > > -- > Scott No, the error was there also when I was loading a real file. But I have to say, the file it was loading did itself also do a document.write of a n empty script tag. The error wasn't inside the JS file though, it was still in the parent page. Before I'd trimmed the JS file down to being just a document.write of an empty script tag, it was trying to load a JS file that was getting a 404. Perhaps that was the problem. Anytime you load either a blank src, or a src that results in a 404, the parent page exhibits a weird XML or parse error in 3 out of the top 5 browsers.
From: Scott Sauyet on 2 Jun 2010 15:40 Joe Nine wrote: > Scott Sauyet wrote: >> Joe Nine wrote: >>> [ ... ] >>> document.write("<scr"+"ipt src=''><\/scr"+"ipt>"); >>> [ ... ] > >> I think the error is because of the empty src attribute in the >> generated SCRIPT element. > >> It's requesting the current document as the source of the script >> element, and when it finds HTML instead of Javascript, it chokes. If >> you said "src='abc'" does the error disappear? > > No, the error was there also when I was loading a real file. But I have > to say, the file it was loading did itself also do a document.write of a > n empty script tag. The error wasn't inside the JS file though, it was > still in the parent page. Don't count on the error location being reported properly when scripts are including other scripts... > Before I'd trimmed the JS file down to being > just a document.write of an empty script tag, it was trying to load a JS > file that was getting a 404. Perhaps that was the problem. Anytime you > load either a blank src, or a src that results in a 404, the parent page > exhibits a weird XML or parse error in 3 out of the top 5 browsers. I don't think a 404 would be an issue. The issue is when the page referenced is not proper JS. If you use a blank "src" attribute, then it's requesting the current HTML file for the JS. That will certainly cause problems. If you requested "myDoc.html", it would probably also cause problems (assuming that file included HTML.) -- Scott
From: Thomas 'PointedEars' Lahn on 2 Jun 2010 15:41 Joe Nine wrote: > <script> > document.write("<scr"+"ipt src=''><\/scr"+"ipt>"); You do not need to separate the start and end tag of the element, respectively. What matters is that the `</' in the end tag is escaped. Otherwise, by SGML parsing rules, it delimits the content of the script element prematurely. (This has been discussed here ad nauseam, and is also pointed out by the W3C Validator when it encounters `</' there.) Therefore, you can use double quotes for attributes in dynamically generated markup, too (makes it easier to make static markup dynamic and vice-versa): document.write('<script src="..."><\/script>'); Not that loading a script like this would be a good idea to begin with. > Earlier it had a head section, the script tags had type on them and It not logical to assume that introducing errors would remove other errors. The `type' attribute is #REQUIRED. Furthermore, but this is not an error, a `script' element in the `body' element may work differently than in the `head' element, depending on the script code thus executed. PointedEars -- var bugRiddenCrashPronePieceOfJunk = ( navigator.userAgent.indexOf('MSIE 5') != -1 && navigator.userAgent.indexOf('Mac') != -1 ) // Plone, register_function.js:16
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: See and Enjoy Indian Girls Gallery. Next: Mousewheel event does not support DOM0 in FF |