IE7 fails on dynamically adding a <form> into a <div>

T

timjowers

Anyone have a work-around for this. Apparently this is MSFT skunk-
security garbage. You can set stuff into the DIV dynamically but not
if its a <form>...

var buga;
var bugastr="<span> __ form>dummy</form></span>";
function demobug(){
alert( "buga=" + buga );
alert( "bugastr=" + bugastr );
document.getElementById("fromListDivCustInfoPicker").innerHTML =
bugastr;
}

function fixme(self) / "self" is the "this" passed from a DIV
onmouseover
{
self.innerHTML='funtimes'; // works fine
alert( "fun? [" + self.name + "] [" + self.id +"]" );
buga="fromListDivCustInfoPicker"; // this is id of the DIV I used
for testing
self = document.getElementById(buga);
alert( "fine? [" + self.name + "] [" + self.id +"]" );
self.innerHTML='fine tums'; // works fine
bugastr="<span> __ form>dummy</form></span>";
demobug(); // works fine
bugastr="<span><form>dummy</form></span>";
demobug(); // FAILS! FAILS! FAILS. (well, works fine in FF :)
}

The last line results in IE7 saying:
Error: Unknown runtime error.
When you bring up their debugger it says:
htmlfile:Unkown runtime error.

<div id='fromListDivCustInfoPicker' style="border-color:black;border-
width:5;background-
color:white;visibility:visible;position:absolute;top:250px;left:40px;z-
index:5;width:45%" onmouseover="fixme(this)">
</div>

Its been years since I did any heavy JavaScript and I'm quite
perturbed to see the same sorry junk programming still exists in the
form of IE. Now I remember why I quit doing javascript.You'd think
BSGates would come off some billions and hire some QA. OK, I just
verified in Firefox 3.0.4 and it works properly.

So, anyone have the workaround for dynamically setting a <form> in a
<div> in IE? Is three some whitepaper on these nasty security/bug/
features in IE?

TIA,
TimJowers
 
J

Jeremy J Starcher

Anyone have a work-around for this. Apparently this is MSFT skunk-
security garbage. You can set stuff into the DIV dynamically but not if
its a <form>...

Post a *complete* page, or URL to a page.

I have only run across this once in IE, when I stuffing things in created
invalid mark-up. (In my case, I was accidentally trying to put a form
inside of a form.)

Using the DOM methods of createElement and family is often a better
solution than using innerHTML. (innerHTML has a number of oddities,
often browser specific.)

[Code snipped]
Its been years since I did any heavy JavaScript and I'm quite perturbed
to see the same sorry junk programming still exists in the form of IE.

IE has its faults, to be sure, but this might not be one of them.
Now I remember why I quit doing javascript.You'd think BSGates would
come off some billions and hire some QA. OK, I just verified in Firefox
3.0.4 and it works properly.

Did you validate the resulting page (after manipulation) to sure that it
did, indeed, work "properly?" Or did it simply do as expected?

HTH,
Jeremy
 
D

David Mark

Anyone have a work-around for this. Apparently this is MSFT skunk-
security garbage. You can set stuff into the DIV dynamically but not
if its a <form>...

Your problem has nothing to do with security.
var buga;
 var bugastr="<span> __ form>dummy</form></span>";
 function demobug(){
        alert( "buga=" + buga );
        alert( "bugastr=" + bugastr );
        document.getElementById("fromListDivCustInfoPicker").innerHTML =
bugastr;
 }

function fixme(self)   / "self" is the "this" passed from a DIV
onmouseover
{
self.innerHTML='funtimes';  // works fine
alert( "fun? [" + self.name + "] [" + self.id +"]" );
buga="fromListDivCustInfoPicker";   // this is id of the DIV I used
for testing
self = document.getElementById(buga);
alert( "fine? [" + self.name + "] [" + self.id +"]" );
self.innerHTML='fine tums';    // works fine
bugastr="<span> __ form>dummy</form></span>";
demobug();   // works fine
bugastr="<span><form>dummy</form></span>";

First off, use valid markup. Why would you try to wrap a form in a
span? Second, why not use appendChild and avoid innerHTML entirely?
demobug();   // FAILS! FAILS! FAILS. (well, works fine in FF :)

}

The last line results in IE7 saying:
Error: Unknown runtime error.
When you bring up their debugger it says:
htmlfile:Unkown runtime error.

<div id='fromListDivCustInfoPicker' style="border-color:black;border-
width:5;background-

Use valid CSS too.
color:white;visibility:visible;position:absolute;top:250px;left:40px;z-
index:5;width:45%" onmouseover="fixme(this)">
 </div>

Its been years since I did any heavy JavaScript and I'm quite

Like downloading large scripts from Dynamic Drive?
perturbed to see the same sorry junk programming still exists in the
form of IE. Now I remember why I quit doing javascript.You'd think

This has nothing to do with the language (or IE's implementation of
it.)
BSGates would come off some billions and hire some QA. OK, I just

I don't think he works there anymore. (?)

[snip]
 
T

timjowers

Anyone have a work-around for this. Apparently this is MSFT skunk-
security garbage. You can set stuff into the DIV dynamically but not if
its a <form>...

Post a *complete* page, or URL to a page.

I have only run across this once in IE, when I stuffing things in created
invalid mark-up.  (In my case, I was accidentally trying to put a form
inside of a form.)

Using the DOM methods of createElement and family is often a better
solution than using innerHTML.  (innerHTML has a number of oddities,
often browser specific.)

[Code snipped]
Its been years since I did any heavy JavaScript and I'm quite perturbed
to see the same sorry junk programming still exists in the form of IE.

IE has its faults, to be sure, but this might not be one of them.
Now I remember why I quit doing javascript.You'd think BSGates would
come off some billions and hire some QA. OK, I just verified in Firefox
3.0.4 and it works properly.

Did you validate the resulting page (after manipulation) to sure that it
did, indeed, work "properly?"  Or did it simply do as expected?

HTH,
Jeremy


Thanks Jeremy,

<form> inside <form> was the problem. I did not try with DOM.

TimJowers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top