理順 JavaScript (1) – 準備工具

來源:互聯網
上載者:User
學 JavaScript 第一個頭痛的問題就是 IDE, 微軟的指令碼編輯器還不錯, 但好像不能獨立安裝; 還是自己做一個吧.

下載最簡單的 JavaScript 測試載入器. 此小工具可能會隨時修改(最新修改時間: 2009-2-25 22:07), 下面是目前的及原始碼:


代碼檔案:
unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, ExtCtrls, StdCtrls, ComCtrls, OleCtrls, SHDocVw, Menus;type  TForm1 = class(TForm)    Panel1: TPanel;    Memo1: TMemo;    Splitter1: TSplitter;    WebBrowser1: TWebBrowser;    PopupMenu1: TPopupMenu;    N1: TMenuItem;    procedure FormCreate(Sender: TObject);    procedure FormClose(Sender: TObject; var Action: TCloseAction);    procedure N1Click(Sender: TObject);  end;var  Form1: TForm1;implementation{$R *.dfm}uses ActiveX;procedure TForm1.FormCreate(Sender: TObject);var  path: string;begin  Text := 'JavaScriptTest';  Position := poDesktopCenter;  WebBrowser1.Navigate('about:blank');  Memo1.ScrollBars := ssBoth;  with Memo1.Font do begin    Name := 'Verdana';    Size := 10;    Color := $000080;  end;  path := ChangeFileExt(ParamStr(0),'.dat');  if FileExists(path) then    ReadComponentResFile(path, Memo1)  else with Memo1.Lines do begin    Clear;    Add('<html>');    Add('<head>');    Add('<title></title>');    Add('<script type="text/javascript">');    Add('alert("Hi");');    Add('</script>');    Add('</head>');    Add('<body>');    Add('JavaScript Test<hr>');    Add('Edit -> F5');    Add('</body>');    Add('</html>');    Self.Text := '編輯代碼後用 F5 重新整理顯示';  end;end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin  WriteComponentResFile(ChangeFileExt(ParamStr(0),'.dat'), Memo1);end;procedure TForm1.N1Click(Sender: TObject);var  ms: TMemoryStream;begin  ms := TMemoryStream.Create;  Memo1.Lines.SaveToStream(ms);  ms.Position := 0;  (WebBrowser1.Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms));  ms.Free;end;end.

表單檔案:

object Form1: TForm1  Left = 0  Top = 0  ActiveControl = Memo1  Caption = 'Form1'  ClientHeight = 303  ClientWidth = 531  Color = clBtnFace  Font.Charset = DEFAULT_CHARSET  Font.Color = clWindowText  Font.Height = -11  Font.Name = 'Tahoma'  Font.Style = []  OldCreateOrder = False  OnClose = FormClose  OnCreate = FormCreate  PixelsPerInch = 96  TextHeight = 13  object Splitter1: TSplitter    Left = 289    Top = 0    Height = 303    MinSize = 1    ExplicitLeft = 219    ExplicitHeight = 196  end  object Memo1: TMemo    Left = 0    Top = 0    Width = 289    Height = 303    Align = alLeft    Lines.Strings = (      'Memo1')    PopupMenu = PopupMenu1    TabOrder = 0    ExplicitHeight = 340  end  object Panel1: TPanel    Left = 292    Top = 0    Width = 239    Height = 303    Align = alClient    BevelOuter = bvNone    Caption = 'Panel1'    TabOrder = 1    ExplicitLeft = 244    ExplicitWidth = 195    ExplicitHeight = 231    object WebBrowser1: TWebBrowser      Left = 0      Top = 0      Width = 239      Height = 303      Align = alClient      TabOrder = 0      ExplicitLeft = 88      ExplicitTop = 88      ExplicitWidth = 300      ExplicitHeight = 150      ControlData = {        4C000000B4180000511F00000000000000000000000000000000000000000000        000000004C000000000000000000000001000000E0D057007335CF11AE690800        2B2E126208000000000000004C0000000114020000000000C000000000000046        8000000000000000000000000000000000000000000000000000000000000000        00000000000000000100000000000000000000000000000000000000}    end  end  object PopupMenu1: TPopupMenu    AutoHotkeys = maManual    Left = 184    Top = 96    object N1: TMenuItem      Caption = #21047#26032      ShortCut = 116      OnClick = N1Click    end  endend

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.