アメブロでスクリプトエラーを回避する方法とは?

このQ&Aのポイント
  • アメブロでテキストボックスに代入するとスクリプトエラーが出る
  • この表示を出さないようにする方法を教えてください
  • C#で作成したプログラムを使用しています
回答を見る
  • ベストアンサー

アメブロで、スクリプトエラーを回避したい

アメブロで、スクリプトエラーを回避する方法を教えてください。 以下のプログラムは、C#で作っています。 アメブロの検索画面にてテキストボックスに代入すると、スクリプトエラーが出ます。 この表示を出さないようにするには、どのようにしたらいいですか。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WebBrowserTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.Text = "MyBrowser"; this.comboBox1.Text = "http://search.ameba.jp/"; //this.comboBox1.Text = "http://www.google.co.jp/webhp?sourceid=navclient-ff"; } /// <summary> /// DocumentCompletedイベントは、ドキュメントの読み込みが終了したときに発生します。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { HtmlElementCollection all = webBrowser1.Document.All; HtmlElementCollection forms = all.GetElementsByName("q"); forms[0].InnerText = @"c#"; // テキストボックスに「C#」を入力 }

質問者が選んだベストアンサー

  • ベストアンサー
  • nmktksk
  • ベストアンサー率36% (75/208)
回答No.1

そのままだとしたら括弧の閉じがたりない。

xcode_15
質問者

補足

もし、かっこの閉じが足りなかったら、ビルドは通らないので考えにくいと思います。 記事へのコピーミスではないでしょうか?

関連するQ&A

  • WebBrowserでgoogle検索するには?

    WebBrowserを使ってgoogle検索をVBで作ったブラウザ上で行いたいです。 具体的には、 「ComboBoxで選択した値」と「TextBoxで書き込んだキーワード」を &検索したいのですが Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted WebBrowser1.Document.All.GetElementsByName("q")(0).InnerText = TextBox1.Text WebBrowser1.Document.All.GetElementsByName("q")(0).InnerText = ComboBox1.SelectedItem WebBrowser1.Document.Forms(0).InvokeMember("submit") End Sub では、&検索ができません。常にコンボボックスで選択されたものだけが 検索され、しかも無限に検索をします。 対処法を教えていただけないでしょうか?

  • C#でstop()が使えない。

    http://kana-soft.com/tech/sample_0012_3.htm#WebBrowser_Stop このHPを参考にstop()メソッドを使おうとしたのですがSTOP()に下記のエラーが出ます。 'System.Windows.Forms.WebBrowser' に 'stop' の定義が含まれておらず、型'System.Windows.Forms.WebBrowser' の最初の引数を受け付ける拡張メソッドが見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足しています。 VS2010を使用し、.NETは4なので問題なく使えると思うのですが原因不明です。 以下ソースです。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace busywait4 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { webBrowser1.Navigate("http://yahoo.co.jp");//もう一度、アクセスしなおす。 } int i; private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { webBrowser1.stop(); }

  • 最後まで読み込ませて待たせるには?

    わからないので質問させてください。 初心者なのでなかなかうまくいきません。(?_?) 教えていただけないでしょうか。 よろしくお願いいたします。 OS VISTA ブラウザ IE7 Microsoft Visual Basic 2005 WindowsFormのWebBrowserを使って表示させています。 やりたいこと WebBrowser1.Navigate(ComboBox1.Text)が読み込むまで待たせたい。 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click WebBrowser1.Navigate(ComboBox1.Text) WebBrowser1.Document.All.GetElementsByName("タイトル")(0).InnerText = TextBox2.Text WebBrowser1.Document.All.GetElementsByName("内容")(0).InnerText = RichTextBox1.Text End Sub

  • VisualStudio 2008 Express

    無料でネットからダウンロードしたVisualStudio 2008 Express Edition のフォームをつかってGUIの勉強をしています。 非情報系学生のための C/C++ 入門 というサイトにある コースの 「第三回  GUI と画像処理プログラミング 」をやってみましたが、フォーム上のボタンを押せばメッセージボックスが出てくるはずなのに、何も起こりません。 何が原因なのかわかりません。詳しい方、どうか知恵を貸してください。  ちなみにそのサイトのアドレスは以下のとおりです。 http://brain.cc.kogakuin.ac.jp/~kanamaru/lecture/prog1/index.html ボタンをフォームに貼り付けると自動的に生成されるイベントハンドラーに、自分の追加した部分も含めたヘッダーファイルの内容を下に乗せておきます。 // *************************** // Form1.h file #pragma once namespace MyGUI_NET { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Form1 の概要 /// /// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた /// マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを /// 変更する必要があります。この変更を行わないと、 /// デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、 /// 正しく相互に利用できなくなります。 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: ここにコンストラクタ コードを追加します // } protected: /// <summary> /// 使用中のリソースをすべてクリーンアップします。 /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::Button^ button1; protected: protected: private: /// <summary> /// 必要なデザイナ変数です。 /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// デザイナ サポートに必要なメソッドです。このメソッドの内容を /// コード エディタで変更しないでください。 /// </summary> void InitializeComponent(void) { this->button1 = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // // button1 // this->button1->BackColor = System::Drawing::Color::PeachPuff; this->button1->Location = System::Drawing::Point(34, 35); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(185, 55); this->button1->TabIndex = 0; this->button1->Text = L"click me"; this->button1->UseVisualStyleBackColor = false; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 12); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(292, 266); this->Controls->Add(this->button1); this->Name = L"Form1"; this->Text = L"Form1"; this->ResumeLayout(false); } #pragma endregion // event handler for button 1 private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { MessageBox::Show("こんにちは"); // 自分が追加した一行 } }; } //****************** どうぞよろしくお願いします。

  • VC2010プログラミング

    formの中に自作のクラスを定義して使用したいのですが、どこに定義すればよいのかわかりません。 #pragma once #include "XXX.h" namespace FileRename { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Form1 の概要 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: ここにコンストラクター コードを追加します // } protected: /// <summary> /// 使用中のリソースをすべてクリーンアップします。 /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::Button^ button1; XXX^ instance = gcnew XXX(); protected: private: /// <summary> /// 必要なデザイナー変数です。 /// </summary> System::ComponentModel::Container ^components;   ・   ・   ・ } XXXクラスはこの場所で定義するのは間違いなのでしょうか?

  • C言語について質問・・・

    柴田望洋氏の著書である明解C言語(入門編)をもとに visual C++を使ってC言語の勉強をしているのですが まず最初に15+37の計算をしようと書いてあり、とりあえず わからない文法だらけだと思うが、下の通りそのまま入力してみよう と書いてあるのですが、その文章をそのまま入力してみたところ いきなりビルドエラーがでてきました。 ↓が実際の文章です。 /* 整数値15と37の和を表示する */ #include <stdio.h> int main(void) { printf("%d",15+37); /*整数値15と37の和を10進数で表示*/ return(0); } ※本書そのままを入力しており、全角半角のミスはないと思います。 しかし、実際新しいプロジェクトを作り立ち上げた瞬間に意味の分からない 文字の羅列が出てきてそのあとに上の文章を書いてあります。 ↓がその文章 #pragma once namespace lesson01 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Form1 の概要 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: ここにコンストラクター コードを追加します // } protected: /// <summary> /// 使用中のリソースをすべてクリーンアップします。 /// </summary> ~Form1() { if (components) { delete components; } } private: /// <summary> /// 必要なデザイナー変数です。 /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// デザイナー サポートに必要なメソッドです。このメソッドの内容を /// コード エディターで変更しないでください。 /// </summary> void InitializeComponent(void) { this->SuspendLayout(); // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 12); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(284, 262); this->Name = L"Form1"; this->Text = L"Form1"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); this->ResumeLayout(false); } #pragma endregion private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { } }; } /* 整数値15と37の和を表示する */ #include <stdio.h> int main(void) { printf("%d",15+37); /*整数値15と37の和を10進数で表示*/ return(0); } となっております。 ※lesson01はプロジェクト名です。 ビルドエラーは 1>------ ビルド開始: プロジェクト: lesson01, 構成: Debug Win32 ------ 1> lesson01.cpp 1>lesson01.cpp(10): error C2731: 'main' : 関数はオーバーロードできません。 1> lesson01.cpp(9) : 'main' の宣言を確認してください。 ========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ========== 保存先はwindows フォームアプリケーションを選び保存しています

  • 【C#】GeckoFXでの読み込み完了

    GeckoFX・Webkit.netなどのブラウザで、DocumentCompletedが複数発生してしまうページの読み込みが完了したことを検知する方法はないでしょうか? 標準のwebBrowserでは if ((sender as WebBrowser).ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete){} とすればよかったのですが、上記のブラウザコントロールにはReadyStateがないのです。 解決できる方がいましたら、どうぞよろしくお願いします。

  • C# フォームを閉じてもプログラムが終了しない

    前略 ・C#の初心者です。 ・下記のようなプログラムを作りたいと思っています。プログラムは<作りたいプログラム>の仕様どうりに動作していますが、Form1のFormClosingイベントに Application.Exit()を追加しないと フォーム1で "X"(閉じる)をクリックしても(フォームは非表示になりますが)プログラムが終了しません。プログラムでどこかおかしな部分があると思っています。Application.Exit()を追加しないでもプログラムを終了する方法を教えてください。 <作りたいプログラム> (1)Form1 のbutton1をクリックすると新しいForm2が作成され表示される。Form2が表示されるとForm1は非表示となる。 (2)Form2 のbutton1をクリックするとForm2が非表示となりForm1が表示される。 (3)Form1 の "X"(閉じる)をクリックしてプログラムを終了する。 //Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace formClose { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form2 form2 = new Form2(); form2.Show(); //フォーム2を表示 this.Hide(); //フォーム1を非表示 } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { Application.Exit(); //アプリケーション終了 } } } //Form2.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace formClose { public partial class Form2 : Form { Form1 form1 = new Form1(); public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.Close(); //フォーム2を閉じる } private void Form2_FormClosing(object sender, FormClosingEventArgs e) { form1.Show(); //フォーム1を表示する } } } 以上

  • キー入力が反応しません。

    VisualStudio2005のC#になります。 ボタンを押す ラベルに文章 ボタン消える Enterキー押す ラベルの文章が変わる という処理を行いたいのですが、”Enterキー押す”以下が実行されません。なぜなのでしょうか?どうすれば実行されるのでしょう。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; namespace 消す { public partial class Form1 : Form { private bool EnterKeyDown; public Form1() { InitializeComponent(); } private void Form1_KeyDown(object sender, KeyEventArgs e) { if (EnterKeyDown == false) { EnterKeyDown = true; label1.Text = "押したよ"; } else { EnterKeyDown = false; label1.Text = "押したよ2"; } } private void button1_Click(object sender, EventArgs e) { button1.Visible = false; } } }

  • 別のフォームの値を初期値として設定するには?

    別のフォームの値を初期値として設定するには どうしたらよいでしょうか? private: System::Void Form2_Load(System::Object^ sender, System::EventArgs^ e) { this->comboBox1->Items = Form1.comboBox1.Items; }