当我选择网页内容的时候激发的事件是什么。选中的是任何内容

解决方案 »

  1.   

    <body onselectstart="document.title='选择了'">
      

  2.   

    补充一下!我是要做一个网页编辑器,窗体是一个内嵌iframe,本身不含body元素
      

  3.   

    iframe里面怎么会没有body元素?
      

  4.   

    <iframe  style="width: 100%; height 100" marginWidth="0" marginHeight="0" frameborder="1" id="MsgFrame" name="MsgFrame" src="about:blank"></iframe>var editor;
    editor = document.getElementById("MsgFrame").contentWindow; 
    //window.frames["MsgFrame"].document.designMode="On"
    editor.document.open();
    editor.document.writeln('<html><head>');
    editor.document.writeln("</head><body></body></html>");
    editor.document.onclick = "alert()";
    editor.document.close();
    editor.document.designMode = 'On';
    editor.document.contentEditable = true;
    editor.document.charset="utf-8";
    我的代码是这样的
    当editor.contentWindow.document.body.onselectstart = function(){}方法加载事件时
    提示body为空,不知道我的方法有没有错
    不过
    <input type="button" onclick='alert(document.getElementById("MsgFrame").contentWindow.document.body.innerHTML)' value="Text" /> 
    的方法可以实现
      

  5.   

    body还没加载
    这句话iframe的onload中,或者设置setTimeout中应该也可以
      

  6.   

    body还没加载 
    editor.contentWindow.document.body.onselectstart = function(){}
    这句话iframe的onload中,或者设置setTimeout中应该也可以