Without knowing "html before" and "html after" can anyone fathom any
reason why the following code crashes IE but if I add <br/> after ANY
<input> tags it doesn't?
*************** *************** *************** *********
HTML = "html before";
HTML += "\
<label for='m-bx'>X:</label><input type='text' id='m-bx'/>\
<label for='m-by'>Y:</label><input type='text' id='m-by'/>\
<label for='m-bw'>Width:</label><input type='text' id='m-bw'/>\
<label for='m-bh'>Height:</label><input type='text' id='m-bh'/>"
HTML += "html after";
bEditor = document.create Element("DIV");
bEditor.innerHT ML = HTML;
dW.appendChild( bEditor);
*************** *************** *************** ********* 14 6093 ni******@hotmai l.com wrote: Without knowing "html before" and "html after" can anyone fathom any reason why the following code crashes IE but if I add <br/> after ANY <input> tags it doesn't?
Doesn't crash IE on my system using document.body for dW. Where does dW
point to?
JW
Janwillem Borleffs wrote: ni******@hotmai l.com wrote: Without knowing "html before" and "html after" can anyone fathom any reason why the following code crashes IE but if I add <br/> after ANY <input> tags it doesn't?
Doesn't crash IE on my system using document.body for dW. Where does dW point to?
dW is just another DIV, and "html before" and "html after" each
represents 100+ lines of html code. Of course I can potentially
eliminate the code line by line and find out the culprit but I'm not
going to do that because it works now anyway and the problem is too
weird that I have absolutely no idea what to look for. I mean, can you
imagine ANY situation where:
"<label for='m-bh'>Height:</label><input type='text' id='m-bh'/><br/>"
works
and
"<label for='m-bh'>Height:</label><input type='text' id='m-bh'/>"
doesn't?
I mean, WTF??
On 5 Nov 2005 05:57:23 -0800, ni******@hotmai l.com wrote: I mean, can you imagine ANY situation where:
"<label for='m-bh'>Height:</label><input type='text' id='m-bh'/><br/>" works and "<label for='m-bh'>Height:</label><input type='text' id='m-bh'/>" doesn't?
Neither are valid HTML, both trigger error correcting modes in IE, if
you're going to avoid a bug, the first thing is to have valid
fragements. IE don't use XHTML in a non-HTML user agent. It's likely
simply that the BR doesn't trigger whatever error recovery IE is doing
to be able to parse the crap you're freeding it.
Jim. ni******@hotmai l.com wrote:
<snip> HTML += "\ <label for='m-bx'>X:</label><input type='text' id='m-bx'/>\ <label for='m-by'>Y:</label><input type='text' id='m-by'/>\ <label for='m-bw'>Width:</label><input type='text' id='m-bw'/>\ <label for='m-bh'>Height:</label><input type='text' id='m-bh'/>" HTML += "html after";
<snip>
You appear to be trying to escape literal line terminators. ECMA 262
explicitly forbids that when it says (in section 7.2) "A line terminator
cannot occur within any token, note even a string literal.". So crashing
IE may be an extreme example of not working, but failing to execute
would be a reasonable expectation of this code as written.
Richard. ni******@hotmai l.com wrote: Without knowing "html before" and "html after" can anyone fathom any reason why the following code crashes IE but if I add <br/> after ANY <input> tags it doesn't?
*************** *************** *************** ********* HTML = "html before"; HTML += "\ <label for='m-bx'>X:</label><input type='text' id='m-bx'/>\ <label for='m-by'>Y:</label><input type='text' id='m-by'/>\ <label for='m-bw'>Width:</label><input type='text' id='m-bw'/>\ <label for='m-bh'>Height:</label><input type='text' id='m-bh'/>" HTML += "html after";
bEditor = document.create Element("DIV"); bEditor.innerHT ML = HTML; dW.appendChild( bEditor); *************** *************** *************** *********
<br /> has nothing to do with your problem. You simply cannot break
string literal by new lines, it's not Visual Basic here ;-)
HTML+= "<label for='m-bx'>X:</label><input type='text' id='m-bx'/>";
HTML+= "<label for='m-by'>Y:</label><input type='text' id='m-by'/>";
.... will fix your problem.
Richard Cornford wrote: ni******@hotmai l.com wrote: <snip> HTML += "\ <label for='m-bx'>X:</label><input type='text' id='m-bx'/>\ <label for='m-by'>Y:</label><input type='text' id='m-by'/>\ <label for='m-bw'>Width:</label><input type='text' id='m-bw'/>\ <label for='m-bh'>Height:</label><input type='text' id='m-bh'/>" HTML += "html after"; <snip>
You appear to be trying to escape literal line terminators. ECMA 262 explicitly forbids that when it says (in section 7.2) "A line terminator cannot occur within any token, note even a string literal.". So crashing IE may be an extreme example of not working, but failing to execute would be a reasonable expectation of this code as written.
OK fair enough. I always thought this is pretty safe hack for a more
readable code. Obviously I had a lot of bad influence over the years :-)
Richard Cornford wrote: You appear to be trying to escape literal line terminators. ECMA 262 explicitly forbids that when it says (in section 7.2) "A line terminator cannot occur within any token, note even a string literal.". So crashing IE may be an extreme example of not working, but failing to execute would be a reasonable expectation of this code as written.
However, the following renders just fine on IE6, FF and Opera: http://playground.jwscripts.com/js-lineseparator.php
So it appears that in some cases, line separators can be applied just
fine...
JW
Janwillem Borleffs wrote: However, the following renders just fine on IE6, FF and Opera:
http://playground.jwscripts.com/js-lineseparator.php
So it appears that in some cases, line separators can be applied just fine...
That is so amazin - I'm speachless! I confirm it works just fine for IE
6.0, FF 1.0.7, Opera 8.1
Of course the escape sign \ must be the very last in the string to kill
the new line terminator (or its 1st part in Windows). That could be the
issue in OP.
Naturally it means *a highly extended reading* of what string literal
means in the program code. As there are not any mentions of this in
official ECMA / JavaScript / JScript docs, I say it's an expoit of the
model behavior ambiguty rather than a new feature.
I'm just dying to know if it was possible on 4th browsers too (Dr.
Stockton, are you here?!) If so then the solution was right in front of
us all these years.
On 6 Nov 2005 05:19:15 -0800, "VK" <sc**********@y ahoo.com> wrote: Janwillem Borleffs wrote: However, the following renders just fine on IE6, FF and Opera:
http://playground.jwscripts.com/js-lineseparator.php
So it appears that in some cases, line separators can be applied just fine... That is so amazin - I'm speachless! I confirm it works just fine for IE 6.0, FF 1.0.7, Opera 8.1
It's worked just about everywhere always, the big difference is what
is in the string, some UA's have a \n in the string, others don't.
I'm just dying to know if it was possible on 4th browsers too (Dr. Stockton, are you here?!) If so then the solution was right in front of us all these years.
It's been generally possible for years, it's still a bad idea, as
Richard Cornford noted, it's not part of ECMASCript, it's an
extension, and as it doesn't add anything we can already do, there's
no point taking the risk.
Jim. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nicolas Van Lancker |
last post by:
Hi folks;
I have this webpage, allowing users to insert multiple records in one post
into the database.
Because I don't know the exact number of records they want to add, I created
a little javascript
that adds a new line with HTML inputboxes and lists to the form if they
press a button.
|
by: necromonger |
last post by:
Hi,
I've got this code that creates a new new row and cell. I then put some
text into the cell with innerHTML - works beautifully with Firefox but
fails with IE. I guess IE doesn't support this way of doing it, but is
there another way of doing it with DOM?
newr = document.createElement('tr');
stbl.appendChild(newr);
|
by: jhcorey |
last post by:
I am doing some maintenance on a js tree control that was done with
proprietary IE code.
When I click on a node it calls a function which has code similar to
that below to expand the tree. "el" refers to the div that I clicked
on.
var workHtml = el.innerHTML;
for (i = 0; i < idx; i++)
|
by: RobG |
last post by:
I know you aren't supposed to use innerHTML to mess with table
structure, but it seems you can't use it just after a table without
damaging the containing element.
I added a table to a div using createElement methods, then added a bit
of extra text using innerHTML, only to find most of the attributes
removed from the table.
Below is a script that calls the same code to add a table inside a
div. It adds an onclick to the div and...
|
by: Jake Barnes |
last post by:
This weekend I wanted to learn AJAX, so I set up a little toy page
where I could experiment. The idea of this page is that you click in
one of the boxes to get some controls, at which point you can add text,
images, or HTML to the box. This seems to work fine in FireFox, but not
in IE. You can see the problem here:
http://www.publicdomainsoftware.org/ajaxExperiment.htm
In FireFox, if you click in a box and then select "Add HTML" you...
| |
by: sonic |
last post by:
Ok,
i am sure everyone is sick of hearing about this. but i've checked
about 10 different posts/sites about this issue, and they all say "use
DOM" but i think there is more to be said. Perhaps I am a total newbie
but the answer was not immediately obvious to me here.
so.. problem:
declaring doctype as xhtml will prevent myDiv.innerHtml=val from
working.
suggested solution:
|
by: SkyZhao |
last post by:
if i use AttachEvent like this,it can't work;
eg:
var img = document.createElement("img");
img.attachEvent("onclick",alert("test"));
var div = document.createElement("div");
div.appendChild(img); //can't work;
div.innerHTML="<-click this";
|
by: Dan Andrews |
last post by:
Hello,
I was wondering what is the correct way to handle special characters
via javascript and the DOM. I would like to avoid document.write and
innerHTML. What I am doing is dynamically creating options for a
select. The innerHTML example below works for firefox and internet
explorer, but is this the accepted way of dynamically adding special
characters.
option = document.createElement("OPTION");
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |