2014-04-02 56 views
0

我想知道我们如何在HTML页面中以编辑模式打开网页。 我的意思是,假设我有两个框架。当我在顶部框架中的文本中输入网址时,我应该在底部页面中以编辑模式访问页面。我应该能够在该模式下选择页面中的项目。我不想保存这些项目,但应该可以通过单击按钮切换到正常模式。在editmode中打开网页

这是为了获取页面中元素的Id/name/xpath。如果在点击时导航到其他页面的页面中有控件,我将无法检测到这些参数。如果我覆盖所有的点击事件,javascript tabs/accradian下的控件将无法访问。

有没有办法做到这一点?

我按照其中一个答案编码,但它不起作用。

<!doctype html> 
<html> 
<head> 
    <title>click demo</title> 
    <script type="text/javascript"> 
     function myFunc() { 
      doc = ifrm.contentDocument || ifrm.contentWindow.document; 
      doc.designMode = "on"; 
     } 
    </script> 
</head> 
<body> 
    <input type="text" id="text" value="http://www.google.com" /> 
    <input type="button" onclick="myFunc()" value="Open" /><br /><br /> 
    <iframe id="ifrm" src="http://www.example.com" width="100%" height="500px" ></iframe> 
</body> 
</html> 
+0

有关使用浏览器的Firebug /开发人员工具是什么?您可以选择任何元素并要求xpath/Css路径 –

+0

谢谢您的回答。但我想用javascript来做,我必须以编程方式来完成。 – Harikrishnan

回答

1

你可以将任何框架设计模式

iframe_node.contentDocument.designMode = "on"; 
+0

是一个跨平台和可编程解决方案? – Harikrishnan