Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

designmode problem

Status
Not open for further replies.

5ilver5aracen

Programmer
Oct 24, 2004
32
0
0
GB
Hi
I've created an editable html page by setting the document.designMode. I'm trying to attach an onBeforePaste event handler to the body of the document now but each time I do this the body cannot be referenced. It shows up as Null. It seems that setting designMode on the document stops you referencing the body. Does anyone know how I can get around this? My simplified code is:

alert(document.body); //=[Object]
document.designMode="On";
alert(document.body); //=null
document.body.onbeforepaste=beforePaste(); //this fails

Many thanks in advance
 
It works fine for me. Several questions spring to mind:

1. Are you waiting for the onload event to fire? If not, you should be.

2. Do you have a DOCTYPE? I tested with a complete and valid XHTML 1.1 DOCTYPE, and found no problems at all.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
>[tt]document.body.onbeforepaste=beforePaste[highlight]()[/highlight]; //this fails[/tt]

Hopefully this would not fail.
[tt]document.body.onbeforepaste=beforePaste;[/tt]
 
Or it might be better?
[tt] window.onbeforepaste=beforePaste;[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top