到外部服务器,ASPX 通过 <script src= 动态发送浏览器 Java 脚本



提前感谢大家的帮助。这是我的一些东西,它在一定程度上起作用。

从国外服务器上的html页面(不是我的)我有这个html行

<script src="http://myserver.xyz/loadthis.aspx?BA_TYPE=1" type="text/javascript"></script>

我的服务器上的"loadthis.aspx"页面加载事件包含以下内容(对于这个问题,我尽可能地简化了它,其中发生了很多事情,但这是问题的主题)

Response.Clear()
Response.Write("document.write('<a href= etc...")
Response.End()
Response.Close()

这非常有效,可以动态加载html

但我也需要一些时间来动态地发送下面这样的脚本。

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-8271739469826977"
data-ad-slot="3666463954"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

我试过这样的事情:其中Str_BACODE为包含上述代码的字符串

Response.Write("document.write('" + StrBA_CODE + "')")
  • 这没有任何作用。我需要使用另一种javascript方法吗正在替换文档.write
  • 我是否首先需要修改我发送的脚本?修改内容/方式

如何解决此问题?

请记住,我的例程(aspx)是从其他网站使用的,而不是我的服务器。

希望我说得足够清楚?谢谢Steve

使用下一个:

Page.ClientScript.RegisterClientScriptInclude("MyTool", "http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js");
Response.Write(@"<ins class='adsbygoogle'
style='display:inline-block;width:728px;height:90px'
data-ad-client='ca-pub-8271739469826977'
data-ad-slot='3666463954'></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>");

最新更新