简体   繁体   English

在我的aspx页面中显示外部网站,并包含自己的JavaScript

[英]Show external website in my aspx page and include own javascript

What I am trying to accomplish: A visitor of my website should be able to load an external website into my website and click elements on this external websites to retrieve the XPath of the element. 我要完成的工作:网站的访问者应该能够将外部网站加载到我的网站中,然后单击该外部网站上的元素以检索该元素的XPath。 Like Firebug but completly online. 类似于Firebug,但完全在线。

I have already managed to create a piece of javascript to click elements on MY website and return the XPath of the element. 我已经设法创建了一段JavaScript,以点击我的网站上的元素并返回该元素的XPath。

Now I need to know how to show an external website in my ASP.NET WebForms page and inject my own javascript. 现在,我需要知道如何在ASP.NET WebForms页面中显示外部网站并注入自己的JavaScript。

I tried to use a literal control and download the external website's HTML code with a WebClient. 我尝试使用文字控件,并通过WebClient下载外部网站的HTML代码。

WebClient webClient = new WebClient();
string result = webClient.DownloadString(txtURL.Text);

litWebsite.Text = result;

Problem here is: The the external website's design will be broken if I don't consider the CSS references. 问题是:如果我不考虑CSS引用,则外部网站的设计将被破坏。 Maybe this is a complete wrong approach. 也许这是一种完全错误的方法。

Any ideas? 有任何想法吗?

Thank you! 谢谢!

I'm not sure it's possible. 我不确定是否有可能。

Sure, you could display the web page via iframe but unless you owned the content, I'm not sure you can control it with your own javascript. 当然,您可以通过iframe显示该网页,但是除非您拥有该内容,否则我不确定您是否可以使用自己的JavaScript对其进行控制。

Maybe I'm wrong but I've always heard that your could do very little with other web content in your own project. 也许我错了,但我一直听说您在您自己的项目中对其他Web内容所做的工作很少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM