<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px">
</OBJECT>
......
var a=dlgHelper.fonts.count;《---------如何在VB中对该对象进行操作啊?
在网上找了好半天都没有结果郁闷...
我想得到这个值dlgHelper.blockFormats.count
var fArray = new Array();
var oDropDown = oToolBar.createDropDownListAt("4");
oDropDown.setAttribute("id","FontNameList");
......
</OBJECT>
......
var a=dlgHelper.fonts.count;《---------如何在VB中对该对象进行操作啊?
在网上找了好半天都没有结果郁闷...
我想得到这个值dlgHelper.blockFormats.count
var fArray = new Array();
var oDropDown = oToolBar.createDropDownListAt("4");
oDropDown.setAttribute("id","FontNameList");
......
set nnn=ttt.getElementById("dlgHelper")
a=ttt.fonts.count用webbrowser控件的话
Set ttt = WebBrowser1.Document
Set nnn = ttt.getElementById("WindowsMediaPlayer1")
End SubPrivate Sub Form_Load()
WebBrowser1.Navigate "file:///E:/vb/webtry/index.htm"
End Sub<html><head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head><body><p>
<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WindowsMediaPlayer1">
<param name="URL" value>
<param name="rate" value="1">
<param name="balance" value="0">
<param name="currentPosition" value="0">
<param name="defaultFrame" value>
<param name="playCount" value="1">
<param name="autoStart" value="-1">
<param name="currentMarker" value="0">
<param name="invokeURLs" value="-1">
<param name="baseURL" value>
<param name="volume" value="50">
<param name="mute" value="0">
<param name="uiMode" value="full">
<param name="stretchToFit" value="0">
<param name="windowlessVideo" value="0">
<param name="enabled" value="-1">
<param name="enableContextMenu" value="-1">
<param name="fullScreen" value="0">
<param name="SAMIStyle" value>
<param name="SAMILang" value>
<param name="SAMIFilename" value>
<param name="captioningID" value>
<param name="enableErrorDialogs" value="0">
<param name="_cx" value="6482">
<param name="_cy" value="6350">
</object>
</p></body></html>用mediaplayer写的,怀疑你自己写错了,如果html可以用这个id的话,我的方法一定没有错的
Private nPara As Object....................
Private Sub Form_Load()
Dim a As Integer
Dim i As Integer
web.Navigate "about: blank" '设置空白页
web.Document.Open '写入当前可编辑内容
web.Document.write "<HTML><HEAD><TITLE>ZCM's PRM</TITLE></HEAD><BODY STYLE='overflow:hidden; margin:0px'></BODY></HTML>"
Set sPara = web.Document
Set nPara = sPara.getElementById("dlgHelper") '调用dlghelper对象
'初始化时将代码写到txtbox中
OutHtmlTxt = web.Document.All(0).outerHTML
a = nPara.BlockFormats.Count
'初始化格式列表框
For i = 1 To a
With Paragraphcob
.AddItem nPara.BlockFormats(i)
.Text = .List(0)
End With
Next
End Sub
显示Run-time error'-2147417848(80010108)' ;
automation error the object invoked has disconnected from its clients. 也就是自动化错误....
web.Document.Open '写入当前可编辑内容
web.Document.write "<HTML><HEAD><TITLE>ZCM's PRM</TITLE></HEAD><BODY STYLE='overflow:hidden; margin:0px'></BODY></HTML>"
Set sPara = web.Document
Set nPara = sPara.getElementById("dlgHelper") '调用dlghelper对象这个是当然的了,你的object还没加载呢,哪找id给你调用的
显示Run-time error'-2147417848(80010108)' ;
automation error the object invoked has disconnected from its clients. 也就是自动化错误....
==========================================================================================
加载后 这条不能运行a = nPara.BlockFormats.Count 显示自动化错误
WebBrowser1.Navigate "about: blank" '设置空白页
WebBrowser1.Document.Open '写入当前可编辑内容
WebBrowser1.Document.write "<HTML><HEAD><TITLE>ZCM's PRM</TITLE></HEAD><BODY STYLE='overflow:hidden; margin:0px'><object classid='clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6' id='WindowsMediaPlayer1'></object></BODY></HTML>"
Set ttt = WebBrowser1.Document
Set nnn = ttt.getElementById("WindowsMediaPlayer1")
End Sub这个也能通过,能不能用getElementbyid是看你加没加载的,我是怀疑你几次都没加载成功
<OBJECT ID=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b"
WIDTH="0px" HEIGHT="0px"></OBJECT>据说ie6上自带的
WebBrowser1.Navigate "about: blank" '设置空白页
WebBrowser1.Document.Open '写入当前可编辑内容
WebBrowser1.Document.write "<HTML><HEAD><TITLE>ZCM's PRM</TITLE></HEAD><BODY STYLE='overflow:hidden; margin:0px'><OBJECT ID='dlgHelper' CLASSID='clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b' WIDTH='0px' HEIGHT='0px'></OBJECT></BODY></HTML>"
Set ttt = WebBrowser1.Document
Set nnn = ttt.getElementById("dlgHelper")End Sub测试通过,我晕,你是什么地方出问题了??
Set ttt = WebBrowser1.Document
Set nnn = ttt.getElementById("dlgHelper")
a = nnn.Fonts.Count
End SubPrivate Sub Form_Load()WebBrowser1.Navigate "about: blank" '设置空白页
WebBrowser1.Document.Open '写入当前可编辑内容
WebBrowser1.Document.write "<HTML><HEAD><TITLE>ZCM's PRM</TITLE></HEAD><BODY STYLE='overflow:hidden; margin:0px'><OBJECT ID='dlgHelper' CLASSID='clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b' WIDTH='200px' HEIGHT='200px'></OBJECT></BODY></HTML>"
End Sub
用command可以,但是不是我所要达到的效果
用一个静态页加载的方法也不行
与command组和使用也不行.......
Call Command1_Click
Timer1.Enabled = False
web.Document.execCommand "editMode"End SubPrivate Sub Command1_Click() '不可见的,在xxx的下层
Set sPara = web.Document
Set nPara = sPara.getElementById("dlgHelper") '调用dlghelper对象
a = nPara.BlockFormats.Count
'初始化格式列表框
With Paragraphcob
For i = 1 To a
.AddItem nPara.BlockFormats(i)
Next
End With
'初始化系统字体
a = nPara.Fonts.Count
With FontNamecob
For i = 1 To a
.AddItem nPara.Fonts(i)
DoEvents
Next
End With
End Sub希望能够找到合适的调用...
function callColorDlg(sColorType){if (sInitColor == null)
//display color dialog box
var sColor = dlgHelper.ChooseColorDlg();
else
var sColor = dlgHelper.ChooseColorDlg(sInitColor);
//change decimal to hex
sColor = sColor.toString(16);
//add extra zeroes if hex number is less than 6 digits
if (sColor.length < 6) {
var sTempString = "000000".substring(0,6-sColor.length);
sColor = sTempString.concat(sColor);
}
//change color of the selected text
document.execCommand(sColorType, false, sColor);
sInitColor = sColor;
oDiv.focus();
}
这个如何翻译成VB啊? 我翻译了半天也不能执行郁闷大概是dlgHelper.ChooseColorDlg不执行..
'颜色相关执行
Public Function callColorDlg(sColorType As String, scolor As Long)
WebEditFrm.web.Document.execCommand sColorType, False, scolorEnd Function
这个函数就ok了
如何插入DIV 或者 TABLE 阿?就是如何获得当前鼠标所在元素的id啊?
set nnn=ttt.createElement("div")给你个vbs的例子function init()set ttt=document.getElementById("sele1")
For i = 1To 50
Set oOption = document.createElement("OPTION")
oOption.Value = i
oOption.text = i
ttt.Add oOption
Set oOption = Nothing
Next
var sFromUrl = d_fromurl.value;
var sWidth = d_width.value;
var sHeight = d_height.value;
var sHTML = "<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
if (sWidth!="") sHTML+=" width="+sWidth;
if (sHeight!="") sHTML+=" height="+sHeight;
sHTML+="><PARAM NAME=movie VALUE='"+sFromUrl+"'><PARAM NAME=quality VALUE=high><embed src='"+sFromUrl+"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash'";
if (sWidth!="") sHTML+=" width="+sWidth;
if (sHeight!="") sHTML+=" height="+sHeight;
sHTML+=">"+sFromUrl+"</embed></OBJECT>";
dialogArguments.insertHTML(sHTML); <<-------------------这里不知道如何实现 window.returnValue = null;
window.close();
}
Public Function insertHTML(html As String) Dim doc As IHTMLDocument2
Set doc = WebEditFrm.web.Document
If LCase(doc.selection.Type) <> "none" Then
doc.selection.Clear
End If
doc.selection.createRange.pasteHTML (html)
Set doc = Nothing
End Function
For i = 1To 50
Set oOption = document.createElement("OPTION")
oOption.Value = i
oOption.text = i
ttt.Add oOption
Set oOption = Nothing
Next
<select id="sele1">
</select>
以前写的了
相关的例程是这样的;
// 光标是否在表格中
var selectedTD
var selectedTR
var selectedTBODY
var selectedTable........function isCursorInTableCell() {
if (eWebEditor.document.selection.type != "Control") {
var elem = eWebEditor.document.selection.createRange().parentElement()
while (elem.tagName.toUpperCase() != "TD" && elem.tagName.toUpperCase() != "TH"){ elem = elem.parentElement <<----这里转化成VB程序后错误
if (elem == null)
break
}
if (elem) { //这里什么意思啊?
selectedTD = elem
selectedTR = selectedTD.parentElement
selectedTBODY = selectedTR.parentElement
selectedTable = selectedTBODY.parentElement
return true
}
}
}*******************************
* 请问各位大侠这里如何实现阿?*
*******************************