小编sup*_*ipd的帖子

IFRAME中的instanceof HTMLElement不是Element或Object?

通过简单检查尝试确定DOM元素

isElement = SomeThing instanceof Element
Run Code Online (Sandbox Code Playgroud)

适用于主文档,但不适用于iframe中的(所有?)节点.

示例输出(谷歌浏览器):(主要文档中的mdiv是DIV,iframe中的id是DIV)

OMGWTF 
ok:  mdiv instanceof Element ... true ... [object HTMLDivElement]
ok:  mdiv instanceof Object ... true ... [object HTMLDivElement]
ko:  idiv instanceof Element ... false ... [object HTMLDivElement]
KO :  idiv instanceof Object ... false ... [object HTMLDivElement] 
Run Code Online (Sandbox Code Playgroud)

主文档和iframe文档有不同的javascript实现???

请解释我的错误.

示例:(http://www.sbmintegral.sk/GITHUB/OMGWTF/obalka.xhtml)

代码:obalka.xhtml(主要文件)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
   <title>Obalka</title>
  </head>
  <body>
    <div id="auto_filled_commands_container">
MAIN div id="auto_filled_commands_container"<br/>
        <iframe id="auto_filled_commands_iframe" src='dopis.xhtml' style="width:98%;height:98%;"/>
    </div>
<div>
<textarea id="OMGWTF" style="width:700px;height:200px">
mdiv = …
Run Code Online (Sandbox Code Playgroud)

javascript iframe element instanceof

9
推荐指数
1
解决办法
2612
查看次数

正则表达式,不能使用

我希望从源代码中提取类似于C的注释

(更新的例子)

/**
 * base comment
 * (c) SOMEBODY SOMETIME
 * something
 */

///<!-- ------metadata-XML------- -->
/// <module type="javascript"> A
///<desc> some desc 
///      </desc> 
(function( a /* param A */) { // programmers comment ... enclosure
/*! user doc
 this module ....
 * reguired
.....
*/
var b={}; // programmers in line comment
// single line comments

// The cookie spec says up to 4k per cookie, so at ~50 bytes per entry
// that gives a maximum of …
Run Code Online (Sandbox Code Playgroud)

regex

1
推荐指数
1
解决办法
108
查看次数

标签 统计

element ×1

iframe ×1

instanceof ×1

javascript ×1

regex ×1