当通过 webbrowsercontrol 运行时,相同的 HTML google adsense 代码会给出不同的结果!

发布于 2024-09-26 08:52:26 字数 1303 浏览 0 评论 0原文

我有这段代码,应该为 google AdSense 生成 HTML 文件,然后使用 Windows 表单应用程序中的 WebBroswerControl 浏览它 奇怪的是,当它通过应用程序运行时,它会生成一个完全没有格式的链接。

但是,如果我直接双击生成的文件,它会给出所需的结果。可能是什么问题?

这是我的代码

         string HTML =
             @"
            <html>
            <script type=""text/javascript"">
            google_ad_client = ""pub-7950118917489847"";
            google_ad_width = 234;
            google_ad_height = 60;
            google_ad_format = ""234x60_as"";

            google_ad_type = ""text"";
            //2008-03-02: hooverwebdesign.com
            google_ad_channel = ""your_ad_channel"";
            google_color_border = ""FFFFFF"";
            google_color_bg = ""FFFFFF"";
            google_color_link = ""0000FF"";
            google_color_text = ""000000"";
            google_color_url = ""008000"";

            google_language = 'en';
            </script><script type=""text/javascript"" src=""http://pagead2.googlesyndication.com/pagead/show_ads.js""></script>
            </html>

            ";

        string adsenseFile1 = Environment.CurrentDirectory + "\\adsense1.html";
        using (StreamWriter writer = new StreamWriter(adsenseFile1))
            writer.Write(HTML);
        webBrowser1.Navigate(adsenseFile1);

I have this code that is supposed to generate HTML file for google AdSense then navigate through it using the WebBroswerControl in a windows forms application
the weird thing is that it produces one link with totally no formatting when it is run through the application.

However, if I double click directly on the produced file, it gives the required result. What could be the problem?

here is my code

         string HTML =
             @"
            <html>
            <script type=""text/javascript"">
            google_ad_client = ""pub-7950118917489847"";
            google_ad_width = 234;
            google_ad_height = 60;
            google_ad_format = ""234x60_as"";

            google_ad_type = ""text"";
            //2008-03-02: hooverwebdesign.com
            google_ad_channel = ""your_ad_channel"";
            google_color_border = ""FFFFFF"";
            google_color_bg = ""FFFFFF"";
            google_color_link = ""0000FF"";
            google_color_text = ""000000"";
            google_color_url = ""008000"";

            google_language = 'en';
            </script><script type=""text/javascript"" src=""http://pagead2.googlesyndication.com/pagead/show_ads.js""></script>
            </html>

            ";

        string adsenseFile1 = Environment.CurrentDirectory + "\\adsense1.html";
        using (StreamWriter writer = new StreamWriter(adsenseFile1))
            writer.Write(HTML);
        webBrowser1.Navigate(adsenseFile1);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

池木 2024-10-03 08:52:26

WebBrowser 控件发送的标头略有不同,请尝试 http://whatsmyuseragent.com/ 进行调查。

WebBrowser control sends a bit different headers, try http://whatsmyuseragent.com/ to investigate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文