当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net - Displaying a web Page's Content on my Webpage which has my custom JavaScript

问题描述:

I want to Display the content of a webpage ( say wikipedia ) on my web page which has my custom JavaScript how shall i do that ?

I tried to use the iFrame for this but the JavaScript that i have on my page doesnt work on the Iframe but it does work on the rest of the body

How should i use the content of a different webpage on my webpage so that i can use my JavaScript on that page.

I want a page like google translator which has on top my Header and on the bottom the content of a webpage.

is it done through an iFrame or a content placeholder or ... what ?

网友答案:

You'll have to fetch the content from your server, build up a page around it (possibly using an <iframe>; that'd certainly be the simplest thing) and then serve it up. There might be all sorts of problems as the page tries to fetch its auxiliary files (CSS, scripts, images) because it may use relative URLs. Depending on what you know about the remote page, you'd have to do some surgery on the fetched content before sending it out to the client.

You cannot mess with content fetched from a different domain. That's why it doesn't work when you just include a frame that directly fetches the other content from the client. When you fetch the content from your server, however, the browser will be happy.

Oh, and also, note that forms or AJAX code in the fetched content may also have problems when running inside your site, because again it may use relative URLs. Even if it isn't, you may have security problems, because there's no way for a user to really log in (unless you proxy that too from your server).

分享给朋友:
您可能感兴趣的文章:
随机阅读: