我试过这个:
string newScript = textBox1.Text;
HtmlElement head = browserCtrl.Document.GetElementsByTagName("head")[0];
HtmlElement scriptEl = browserCtrl.Document.CreateElement("script");
lblStatus.Text = scriptEl.GetType().ToString();
scriptEl.SetAttribute("type", "text/javascript");
head.AppendChild(scriptEl);
scriptEl.InnerHtml = "function sayHello() { alert('hello') }";
Run Code Online (Sandbox Code Playgroud)
scriptEl.InnerHtml和scriptEl.InnerText都给出了错误:
System.NotSupportedException: Property is not supported on this type of HtmlElement.
at System.Windows.Forms.HtmlElement.set_InnerHtml(String value)
at SForceApp.Form1.button1_Click(Object sender, EventArgs e) in d:\jsight\installs\SForceApp\SForceApp\Form1.cs:line 31
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at …Run Code Online (Sandbox Code Playgroud) 任何人都知道.NET的一个好的免费winforms html编辑器.理想情况下,我想要html和预览模式以及导出到pdf,word doc或类似的可能性.
虽然导出我可能会从html输出创建自己.
另一个不错的功能是从单词粘贴,删除你通常最终得到的所有额外标签,但再次,没有必要的很好.
我问这个问题因为我们将开发一个应用程序,它应该通过javascript共享交叉源数据.一种可能的解决方案似乎是JSONP,因为它使用SCRIPT标签从其他域中提取数据.但是,我想避免我们在假设SCRIPT标记不受sop限制的情况下实现我们的强大代码的情况,并且在某些时候浏览器禁止此功能.
任何人都可以了解SCRIPT标签允许跨域请求的原因是什么?