当通过 webbrowsercontrol 运行时,相同的 HTML google adsense 代码会给出不同的结果!
我有这段代码,应该为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WebBrowser 控件发送的标头略有不同,请尝试 http://whatsmyuseragent.com/ 进行调查。
WebBrowser control sends a bit different headers, try http://whatsmyuseragent.com/ to investigate.