将要访问的网页:Index.html 代码
******************************<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gbk" />
<script>
var BOSS_NAME='BOSS';
var CRM_NAME='CRM';
var cityID = '700';
function getActiveIframe()
{
alert('GetiFrame');
if (top.ClientiFrame)
{
return document.getElementById("ClientiFrame");
}
else
{
return null;
}
}function getInfo()
{
var clDoc = getActiveIframe() ;
alert(clDoc.contentWindow.document.title);
var atTitle = clDoc.contentWindow.document.title;
var clTitle = document.getElementById("ClientiFrame").contentWindow.document.title;
var topTitle = document.getElementById("TopiFrame").contentWindow.document.title; document.open;
document.write("GetiFrame: " + atTitle + "<br>" );
document.write("clTitle):" + clTitle + "<br>" );
document.write("topTitle:" + topTitle+ "<br>" );
document.write(BOSS_NAME+ "<br>" );
document.write(CRM_NAME+ "<br>" );
document.write(cityID+ "<br>" );
}function Button1_onclick() {
getInfo();
}</script>
</head>
<body>
<h1>NEWS WEBSITE</h1>
<p>some text. some text. some text...</p>
... <div class="iFrame1">
<h2> IFrame 1</h2>
<iFrame id="TopiFrame" name="TopiFrame" width="99%" height="60"
src="iframe1.html" frameborder=0 scrolling=no > </iframe>
</div> <div class="iFrame2">
<h2> IFrame 2</h2>
<iframe id="ClientiFrame" name="ClientiFrame" width="99%" height="60"
src="iframe2.html" frameborder=0 scrolling=no > </iFrame>
</div>
<div class="iframe3" >
<form id="form1">
<input type="button" value="Show" id="Button1" name="Button1" onclick="Button1_onclick()">
</form>
</div>
</body>
</html>**************************iframe1.html 代码
****************************** <html>
<head>
<title>Iframe 测试1 </title>
Iframe 测试1
</head>
</html>******************************问题是:
用IE打开 Index.html 网页 1、 取得IE的句柄后,怎样访问 Index.html 网页的变量 BOSS_NAME 、 对象getActiveIframe ??? 我如果用 TWebBrowser 控件打开 网页则可以这样访问:
var
ve: OleVariant;
CurWindows:IHTMLWindow2;
spDisp:IDispatch;
begin
//访问变量 BOSS_NAME
ve := WebBrowser1.OleObject.document.parentWindow.BOSS_NAME ;
showmessage(ve); //反问对象变量Iframe getActiveIframe
WebBrowser1.OleObject.document.parentWindow.eval(' var ActiveIFrame ');
WebBrowser1.OleObject.document.parentWindow.eval(' ActiveIFrame = getActiveIframe() ');
ve := WebBrowser1.OleObject.document.parentWindow.ActiveIFrame ;
spDisp:= WebBrowser1.OleObject.document.parentWindow.ActiveIFrame.contentWindow ;
spDisp.QueryInterface(IHTMLWindow2 ,CurWindows); showmessage(CurWindows.document.title);
end;
请各位大侠指点指点
******************************<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gbk" />
<script>
var BOSS_NAME='BOSS';
var CRM_NAME='CRM';
var cityID = '700';
function getActiveIframe()
{
alert('GetiFrame');
if (top.ClientiFrame)
{
return document.getElementById("ClientiFrame");
}
else
{
return null;
}
}function getInfo()
{
var clDoc = getActiveIframe() ;
alert(clDoc.contentWindow.document.title);
var atTitle = clDoc.contentWindow.document.title;
var clTitle = document.getElementById("ClientiFrame").contentWindow.document.title;
var topTitle = document.getElementById("TopiFrame").contentWindow.document.title; document.open;
document.write("GetiFrame: " + atTitle + "<br>" );
document.write("clTitle):" + clTitle + "<br>" );
document.write("topTitle:" + topTitle+ "<br>" );
document.write(BOSS_NAME+ "<br>" );
document.write(CRM_NAME+ "<br>" );
document.write(cityID+ "<br>" );
}function Button1_onclick() {
getInfo();
}</script>
</head>
<body>
<h1>NEWS WEBSITE</h1>
<p>some text. some text. some text...</p>
... <div class="iFrame1">
<h2> IFrame 1</h2>
<iFrame id="TopiFrame" name="TopiFrame" width="99%" height="60"
src="iframe1.html" frameborder=0 scrolling=no > </iframe>
</div> <div class="iFrame2">
<h2> IFrame 2</h2>
<iframe id="ClientiFrame" name="ClientiFrame" width="99%" height="60"
src="iframe2.html" frameborder=0 scrolling=no > </iFrame>
</div>
<div class="iframe3" >
<form id="form1">
<input type="button" value="Show" id="Button1" name="Button1" onclick="Button1_onclick()">
</form>
</div>
</body>
</html>**************************iframe1.html 代码
****************************** <html>
<head>
<title>Iframe 测试1 </title>
Iframe 测试1
</head>
</html>******************************问题是:
用IE打开 Index.html 网页 1、 取得IE的句柄后,怎样访问 Index.html 网页的变量 BOSS_NAME 、 对象getActiveIframe ??? 我如果用 TWebBrowser 控件打开 网页则可以这样访问:
var
ve: OleVariant;
CurWindows:IHTMLWindow2;
spDisp:IDispatch;
begin
//访问变量 BOSS_NAME
ve := WebBrowser1.OleObject.document.parentWindow.BOSS_NAME ;
showmessage(ve); //反问对象变量Iframe getActiveIframe
WebBrowser1.OleObject.document.parentWindow.eval(' var ActiveIFrame ');
WebBrowser1.OleObject.document.parentWindow.eval(' ActiveIFrame = getActiveIframe() ');
ve := WebBrowser1.OleObject.document.parentWindow.ActiveIFrame ;
spDisp:= WebBrowser1.OleObject.document.parentWindow.ActiveIFrame.contentWindow ;
spDisp.QueryInterface(IHTMLWindow2 ,CurWindows); showmessage(CurWindows.document.title);
end;
请各位大侠指点指点
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货